First , overview:
an object -and event- driven scripting language developed by Netscape. is designed to add interactive behavior to HTML pages. No compilation is required and the browser can interpret the run directly. is a weakly typed language. The official name of JavaScript is "ECMAScript", a standard that has been developed and maintained by the ECMA organization.
features:
interactivity (what it can do is dynamic interaction of information)
Security (does not allow direct access to local hard disks)
Cross-platform (as long as the browser can interpret JS can be executed, and platform-independent)
Second, the language composition : A complete JavaScript implementation consists of
3 parts: • Core (ECMAScript) • Document Object Model (DOM) • Browser object model (BOM)
third, the combination of JS and HTML way:
1, embedded mode: <script type= "Text/javascript" >//Deprecated language= "javascript" attributealert (1);
</script>
2. How to import: <script src= "01.js" ></script>JavaScript code cannot be written between script tags that reference external JS
3, in-line mode: (can achieve effect, but less use) <input type= "text" onclick= "Javascript:var a=20; alert (a)" ></input>
iv. basic Syntax: ·
variables, functions, case-sensitive ·
variable is weak type var a = ten;var B = true;var c = "Hello";
· A semicolon can be omitted if there is no other code at the end of a line of code If you have code later, you need to add a semicolon. But it is recommended to write ·
Two types of annotations //* * * ·
two types of data
Original value: Undefined, Null, Boolean, number, and String Reference value: (view variable types by typeof; Instanceof to detect whether an object belongs to a class) • Operator Two yuan, ternary, comparison • Process Control Note the difference between break and continue
definition of function: Way One:
remember the first kind of line, two or three less use function Add (A, b) {return a + B;
} function does not need to define a return value, it can return directly Way Two:var add2 = function (A, b) {
return a+b;
}
Way Three:var add3=new Function (' A ', ' B ', ' C ', ' c=c+1; return a+b+c; ');
Vi. Global functions: (Refer to help manual for specific use) The Global object is a predefined object, not a class. Neither constructor nor instantiation of a new global object isNaN Check if a value is a number parseint/parsefloat parsing strings as integers/floating-point numbers eval to execute JavaScript strings as script code eval ("X=10;y=20;document.write (x*y)") Escape and Unescape, encodeURI () and decodeURI () The escape function encodes the string (in Chinese) so that it can be read on all computers
Seven, the commonly used object introduction: Array object , array manipulation String Object-----A reference type of type Number Object----Numeric primitive type reference type Boolean Primitive type reference type---- a Boolean object Math Object performs mathematical tasks Date objects are used to process dates and times
---javascript basic finishing