Let's see basic type and grammar of javascript. I assume that reader of this document have a basic programming experience. so, I will not explain everything in detail. We'll see javascript specific things and something is good to know. Learning test is written using Jasmine. Please refer Jasmine usage which I wrote before if you have interest it.
1. Javascript is dynamic typing programming language
It means that you don't need to specify type whenever declare variable. The type will be converted in run-time. In following example, We just use keyword "var" without specifying any type. It is also possible to use without explicit type casting. (Of course, programmer should careful when use it)2. Variable
If you declare variable without "var", It means that you declare global variable. Please refer [line 9] , [line13] of following example closely.3. undefined, null
If you just declare variable but not to assign any value, it will be treated as "undefined". But depend on context, you can see that undefined and null are converted dynamically. "undefined" is treated as NaN(Not a Number) in decimal context. But "null" is treated as 0.4. constant
The variable name and function name which are declared with "constant" cannot be redeclared.5. Array
Javascript Array is quite similar with general programming's array. Let's see [line 6]. If there are no value, it is treated as an undefined.6. Object
You need to see how to declare object and how to access its member closely. Like [line 9], If the member's name is decimal, You can use it like Array. But, if the name is not decimal, you should use like [line 4] or [line6]. You cannot use like [line 8]. It will cause javascript error.7. Reference
- MDN - https://developer.mozilla.org/en/docs/Web/JavaScript- Jasmine - http://jasmine.github.io/2.3/introduction.html
댓글 없음:
댓글 쓰기