true == 1; //true! (converts true to bit value 1) true - false === 1 //true!!! "2" + 2; //22! "2" - 2; //0 "2" - - 2; //4 NaN == NaN; //false - this one sort of makes sense since NaN is any non-Number cast to a number NaN NaN; //false - whatever! "" == 0 //true undefined == null //false! "0" == 0 //true! "false" = false //false!!!' '\t\r\n ' == 0 //true!!! if(-1) {....} //true if("") {....} //fa..
1. simple Object Literal var myApp = {}; myApp.panel = {}; myApp.panel.toggleDisplay = function() { this.displayed = (this.displayed==="none")? "" : "none"; } myApp.panel.defaultWidth = 300; myApp.notepad = {}; myApp.notepad.writeable = true; myApp.notepad.font = 'helvetica'; myApp.notepad.setFont = function(theFont) { myApp.notepad.font = theFont; } //OK not inheritance at all. But best we can ..
1. Simple Object Literal myApp.notepad = {}; myApp.notepad.writeable = true; myApp.notepad.font = 'helvetica'; myApp.notepad.setFont = function(theFont) { myApp.notepad.font = theFont; } 2. Nested Object Literal myApp.notepad = { writeable: true, font: 'helvetica', setFont: function(theFont) { this.font = theFont; } } 3, Constructor using Object Literal myApp.Notepad = function(defaultFont) { va..
var whatToBring; switch(weather) { case "Sunny": whatToBring = "Sunscreen and hat"; break; case "Rain": whatToBring ="Umbrella and boots" break; case "Cold": whatToBring = "Scarf and Gloves"; break; default : whatToBring = "Play it by ear"; } ------------------------------------------------ var whatToBring = { "Sunny" : "Sunscreen and hat", "Rain" : "Umbrella and boots", "Cold" : "Scarf and Glov..
수 ( Numbers ) Javascript 에서 수는 "이중 정밀도 64비트 형식 IEEE 754 값" 으로 정의 됩니다. 0.1 + 0.2 = 0.30000000000000004 뎃셈, 뺄셈, 계수 ( 또는 나머지 ) 연산을 포함하는 표준 산술 연산자가 지원됩니다. Math.sin(3.5);d = Math.PI * r * r; 내장 parseInt() 함수를 사용하여 문자열을 정수로 변한 할 수 있수 있습니다. 다음과 옵션으로 주어지는 변수를 지정할수 있다. > parseInt("123", 10)123> parseInt("010", 10)10 옵션을 주지 않으면 , 다음과 같이 예상치 못한 결과를 얻는다. > parseInt("010")8 이 같은 결과는 parseInt 함수가 0으로 시작되는 문자열..