Comments (11)
Here's what babel transpiles it to:
I don't think the argument
object itself is deprecated. I know of arguments.callee
. Besides, Babel transpiles to arguments too so i'd say it isn't that bad to use.
P.S: I think @jeresig is trying to avoid using es6, so it's best we don't add it. Why? It makes it all easy.
And the arguments.callee
he used was just for illustration which was backed by the named function.
from advanced-javascript.
Okay. Es6 out. I think the source is old though. Really nice repo.
I wonder why people still prefer constructors to factory functions though
from advanced-javascript.
I think it all boils down to the implementation details 😅
Although, it does reduce the number of new keywords. Still, it seem a lil bit Verbose compared to the Constructor Pattern.
from advanced-javascript.
while trying out one of your quizzes. I did this
function Ninja(){
this.name = "Ninja";
}
assert(name === "Ninja", "Ooops!, leaked out")
And you can guess the outcome 😄
Kyle Simpson and Eric Elliot prefer factory functions though, but as you said, it all boils down to implementation details.
from advanced-javascript.
It's not mine... Full credits to John Resig...
You should get something like name is not defined
Except you called Ninja which in turn, attaches name to the global context?
from advanced-javascript.
This actually
function Ninja(){
this.name = "Ninja";
}
var ninjaA = Ninja(); // This line does the magic
assert( name === "Ninja", "Is undefined, not an instance of Ninja." );
assert( !ninjaA, "Is undefined, not an instance of Ninja." );
from advanced-javascript.
@ashinzekene Yeah, Obviously. By calling it that way, name get attached to the global context. The new
keyword changes/prevents that :)
from advanced-javascript.
Nice 😀
from advanced-javascript.
I just wrapped my head around the fact that the this
bonding occurs at the call site which is the global context like you said. Did you read Kyle Simpson's book?
from advanced-javascript.
I read it. That's great. Kyle is awesome 🌟
from advanced-javascript.
Really awesome. Cool. No wonder you're a boss 😂
from advanced-javascript.
Related Issues (2)
- Typographic errors HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from advanced-javascript.