JavaScript 코드 작성
var aBird = "Robin"; // Assign the text "Robin" to the variable aBird. var today = new Date(); // Assign today's date to the variable today.
function inchestometers(inches) { if (inches < 0) return -1; else { var meters = inches / 39.37; return meters; } } var inches = 12; var meters = inchestometers(inches); document.write("the value in meters is " + meters);
var aGoodIdea = "Comment your code thoroughly."; // This is a single-line comment.
/*
This is a multiline comment that explains the preceding code statement.
The statement assigns a value to the aGoodIdea variable. The value,
which is contained between the quote marks, is called a literal. A
literal explicitly and directly contains information; it does not
refer to the information indirectly. The quote marks are not part
of the literal.
*/
참고 |
---|
// This is another multiline comment, written as a series of single-line comments. // After the statement is executed, you can refer to the content of the // aGoodIdea variable by using its name. var extendedIdea = aGoodIdea + " You never know when you'll have to figure out what it does.";
변수 배열 요소 개체 속성
var anInteger = 3;
3.9 // numeric literal "Hello!" // string literal false // boolean literal null // literal null value {x:1, y:2} // Object literal [1,2,3] // Array literal function(x){return x*x;} // function literal
var anExpression = 3 * (4 / 5) + 6; var aSecondExpression = Math.PI * radius * radius; var aThirdExpression = aSecondExpression + "%" + anExpression; var aFourthExpression = "(" + aSecondExpression + ") % (" + anExpression + ")";
from MSDN : https://msdn.microsoft.com/ko-kr/library/cte3c772(v=vs.94).aspx
///844.
'지속가능티끌 > JavaScript' 카테고리의 다른 글
JavaScript. 함수 (Functions) (0) | 2016.07.27 |
---|---|
JavaScript. 연산자, 우선순위. Operators. (0) | 2016.07.27 |
JavaScript. 변수 (Variable). 전역,지역 (0) | 2016.07.27 |
JavaScript. 프로그램 흐름제어. if,while, for, break, continue. (0) | 2016.07.27 |
JavaScript. 내장개체(built-in object). Number, Array, Math, String, Date, JASON (0) | 2016.07.27 |
댓글