👋 Developers! ❤️ Save for Later!
#tinyfrontend #webdevelopment #frontend
👋 Developers! ❤️ Save for Later!
Do you know any differences between the Arrow and Regular functions?
here are 4 main differences, please continue watching.
No. 1, this bindings.
- Regular function has its own this binding, usually points to itself.
- Arrow function inherits the this value from the enclosing scope where the function was defined. It does not have its own this binding.
No.2, the arguments object.
- Regular function has an arguments object that holds all the arguments passed to the function.
- Arrow Function doesn’t have its own arguments object. However, you can use the rest parameters syntax to gather arguments.
No. 3, used as constructors.
- Regular Function can be used as a constructor function with the new keyword to create instances of objects.
- But Arrow Function cannot and will throw an error if used with new.
No. 4, access before initialization.
- Because all functions and variables in JavaScript are hoisted, the regular functions can be accessed before initialization.
- But the arrow function will throw an exception.
This is the 1 minute sharing for today.
Please give us a like, and share it with your friends!
#TinyFrontend #WebDevelopment #frontend #frontenddeveloper #frontenddev #frontenddevelopment #frontendwebdeveloper #frontendengineer #frontendengineering #frontendmasters #html #CSS #JavaScript #Function #arrowfunction
Comments
Comments from the original post on Instagram
No comments yet
