Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How coercion works behind the scenes #7796

Open
ravi-ranjan-singh opened this issue Jan 21, 2023 · 3 comments
Open

How coercion works behind the scenes #7796

ravi-ranjan-singh opened this issue Jan 21, 2023 · 3 comments
Labels
question Further information is requested topic suggestion Suggestion for a new article.

Comments

@ravi-ranjan-singh
Copy link

Coercion and Abstract operations in Javascript.

Proposed title of the article

How coercion works behind the scenes

Proposed article introduction

You must have experienced a case where people are trying to bash Javascript by showing how bizarre it is while surfing the internet. This is one of the cases that you must have found :

console.log(""==[])
// this returns true

And you see, "Weird" is a short-lived term unless you comprehend how it's actually working. This is one of the cases where if you don't understand coercion, this will seem a like a bug in JS. Therefore, understanding coercion in JavaScript properly is important because not only it will help new developers to write better and understandable code, but it will also help other developers to avoid bugs that can occur due to not understanding coercion.

In this article, I will explain how coercion works in JavaScript and how it works behind the scenes. We will also have a look at abstract operations, which is the core concept behind coercion.

Key takeaways

At the end of this article, readers would be able to:

  • Readers will know what coercion in Javascript is.
  • Reader will know what abstract operations are.
  • Reader will know how coercion works under the hood.

Conclusion

In this article, we leaned what coercion is and how it works under the hood using abstract operations. We also saw implicit versus explicit typecasting and learned about the concept of boxing in Javascript.

Javascript being a beginner-friendly language comes with its caveat around typecasting, therefore it is important to know all these concepts to avoid these caveats as this will help you avoid bugs in your code and your coercion to your advantage instead of avoid it.

@ravi-ranjan-singh ravi-ranjan-singh added the topic suggestion Suggestion for a new article. label Jan 21, 2023
@github-actions
Copy link

👋 @ravi-ranjan-singh
Good afternoon and thank you for submitting your topic suggestion.
Your topic form has been entered into our queue and should be reviewed (for approval) as soon as a content moderator is finished reviewing the ones in the queue before it.

@WanjaMIKE
Copy link
Contributor

@ravi-ranjan-singh still working on this?

@WanjaMIKE WanjaMIKE added the question Further information is requested label Apr 6, 2023
@ravi-ranjan-singh
Copy link
Author

@WanjaMIKE I have the draft nearly ready but I saw my topic wasn't approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested topic suggestion Suggestion for a new article.
Projects
None yet
Development

No branches or pull requests

2 participants