<script>
function Foo(i, j){
var i=i;
var j=j;
var a=3;
alert(i);
alert(this.i);
}
var foo = new Foo(1,2);
</script>
The result is "1" and "undefined",so we can conclude that the the "var i" is not a property belong to Object foo. It is a variable can be used in this function(notice:treat it as a function) ,but is not a property the class(I conside it as a java class).
<script>
function Foo(i, j){
var i=i;
var j=j;
var a=3;
alert(i);
alert(this.i);
}
var foo = new Foo(1,2);
</script>
In this way ,we declare a property named "i" of class Foo. and we can use the property of Object foo:
<script>
alert(foo.i);
</script>
分享到:
相关推荐
looking for the quantum leap towards mastering the JavaScript language, or just want to become a better programmer in general, then this book is ideal for you. It is aimed at programmers involved in ...
looking for the quantum leap toward mastering the JavaScript language, or just want to become a better programmer in general, then this book is ideal for you. This guide is aimed at programmers, ...
在这个由Laurie Voss, co-founder and COO of npm, Inc. 所做的研究中,我们可以通过该文档了解到2018年JavaScript的回顾以及npm对未来2019年的JavaScript开发趋势的预测。从这项研究中,我们能够提取出一些关键知识...
In complex web applications, the low-level details of your JavaScript code can obscure the workings of the system as a whole. As a coding style, functional programming (FP) promotes loosely coupled ...
This course offers an expert's eye on the latest ES6 features and how these advanced tasks fit together in JavaScript as a whole Discover robust JavaScript implementations of classic and advanced ...
In depth discussion of data types, operators, and flow control statements in JavaScript In depth discussion of functions, function usage patterns, and variable scope Understand how prototypes work ...
The book first explores the core concepts of functional programming common to all functional languages, with examples of their use in JavaScript. It's followed by a comprehensive roundup of functional...
Study note on htis keyword in JavaScript
This guide to JavaScript builds on the success of previous editions and introduces you to many new advances in JavaScript development. The reorganization of the chapters helps streamline your ...
### JavaScript in 10 Minutes: Key Insights for Intermediate and Advanced Programmers #### Introduction "JavaScript in 10 Minutes" is a concise guide that aims to provide intermediate to advanced ...
This Fifth Edition is completely revised and expanded to cover JavaScript as it is used in today's Web 2.0 applications. This book is both an example-driven programmer's guide and a keep-on-your-desk ...
oriented programming accessible and understandable to web developers Write better and more maintainable JavaScript code while exploring interactive examples that can be used in your own scripts Who ...
and other language-specific categories, the abstractions and code templates in this guide are ideal -- whether you're writing a client-side, server-side, or desktop application with JavaScript....
console.log('I am in Grade ' + this.grade); }; ``` 这里,我们首先获取了`sayHello`方法在父类原型上的引用,然后通过`call`方法将其绑定到当前对象(`this`),确保上下文正确。这样,`Student`类的`sayHello`...
No matter how long you’ve been writing JavaScript code, Effective JavaScript will help deepen your understanding of this powerful language, so you can build more predictable, reliable, and ...
This book provides a developer-level introduction along with more advanced and useful features of JavaScript. Coverage includes: JavaScript use with HTML to create dynamic webpages, language concepts ...