Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic knowledge points of JavaScript

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what are the basic knowledge points of JavaScript". In the daily operation, I believe that many people have doubts about the basic knowledge points of JavaScript. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions of "what are the basic knowledge points of JavaScript?" Next, please follow the editor to study!

Overview of 1.javascript (understanding)

1. What is javascript?

Javascript, referred to as js for short, is a running environment for js, a scripting language running in the js interpreter / engine: 1. Independently installed js interpreter (node) 2. Js interpreter embedded in browser kernel

The Development History of 2.js

1. In 1992, Nombas developed a scripting language LiveScrpt for itself. In 1995, Netscape (Netscape) developed a scripting language LiveScrpt, which was later renamed javascript3.1996 year Microsoft cloned javascript,JScript4.1997 year in IE3.0 version, and javascript was submitted to ECMA (European Federation of computer Manufacturers). Define ECMAScript, or ES5,ES6 for short

3.js component

1. Core (ECMAScript) 2.DOM (Document object model) document object model 3.BOM (Browser object model) browser object model

Characteristics of 4.js

1. The syntax is similar to cPower java 2. No need to compile, run 3. 0 directly by js interpreter. Weakly typed language 4. The basic syntax of object-oriented 2.JavaScript

1. Use javascript

1. Set up the running environment 1. Independently installed JS interpreter-NodeJS 1. In the command line interface: enter node console.log ("Hello, World"); print out instructions on the console: js can run 2. 0 independently in the js interpreter. Using the js interpreter embedded in the browser kernel, the browser kernel is responsible for rendering the page content, which consists of two parts: content typesetting engine-parsing: HTML/CSS script interpretation engine-parsing: javascript 1. Enter the script directly in the Console (console) and run 2. Embed the js script in the event that executes the 1.html element in the HTML page to execute the js script event-the action to be performed by onclick- when the mouse is clicked. 2. Wherever you write a script in and execute the page, embed a pair of tags and write the script in the tag. 3. Use an external script file (suffix .js) 1. Create a script file (.js) and write a script in the file. In the use of web pages to reference the script file 3.js debugging, F12 to view errors, errors do not affect other blocks of code, the subsequent code continues to execute. / * this script error * / document.writ ("Zhou Zhi Ruo"); / * continue execution * / console.log ("Jinhua mother-in-law"); 3. Through grammatical specification 1. Statement: the smallest executable unit must end with a strict distinction between sizes and all symbols must be in English 2. Comments: / /: single-line comments / * /: multi-line comments 3. Variables and constants

1. Variable declaration

1. Declare variable var variable name; 2. Assign a value to the variable name = value; 3. Declaration variable is directly assigned var variable name = value; ex: var uname= "Zhang Wuji"; var age=20; Note: 1. Allows multiple variables to be declared in a statement, separated by commas. Var uname= "Han Meimei", uage=20; 2. If a variable is declared but no value is assigned, the value defaults to undefined 3. 0. Var may not be applicable when declaring variables, but uname= "tom" is not recommended

two。 Specification of variable names

1. It is not allowed to start with a number 2. The use of keywords and reserved keywords are not allowed. It is best to see the name and meaning of var uname; var uage;4. Allowed to include letters, numbers, underscores (_), $var $name= "Tom"; 5. Try to use small hump nomenclature var userName; var uname; var _ uname;// underscore var user_name;// underscore var UserName;// big hump nomenclature 4. The use of variables 1. The declaration variable is not assigned, and the value defaults to undefined2. Use undeclared variables to report error 3. The variable name of the assignment operation appears on the left side of =, and it is always the assignment operation var uname= "Sister Lin"; 4. As long as the value operation variable does not appear to the left of =, it is always the value operation var uage=30;console.log (uage); var num1=uage;5. Constant 1. What is a constant in a program, once declared, the data that is not allowed to be modified is a constant. two。 Syntax const constant name = value; constant name in a program is usually in uppercase. Const PI=3.1415926;5.1 data type

1. The role of data types

Specifies the space occupied by data in memory 10.1 64-bit 8-byte bit: bit 8bit=1byte byte 1024byte=1KB 1024KB=1MB1024MB=1G 1024G=1T

two。 Detailed explanation of data types

1. Data types are divided into two categories: primitive type (basic type) reference type 1. Primitive type 1.Number type numeric type function: can represent 32-bit integers or 64-bit floating-point (decimal) integers: 1. Decimal system 10 2. Octal consists of eight digits from 0 to 7, starting with 0 in every octal var num=010; 3. 0. Hexadecimal consists of 0-9 and Amurf Every hexadecimal number: a floating point number starting with 0X in the hexadecimal system: also known as 3.4e3 decimal point counting method: 12.58 exponential counting method: 3.4e3 (3.4mm 10 to the third power of) 2.String type string function: represents a series of text character data, such as name, gender Address. Each character in a string is made up of Unicode characters, punctuation and numbers. Unicode code: each character in the computer has a unique code to represent the character, this code is Unicode code (he is hexadecimal) 1. Find the unicode code of one character: "Li" .charCodeAt (); / 10 output "Li" .charCodeAt (). ToString (2); / / binary output "Li" .charCodeAt (). ToString (16); / / unicode code of hexadecimal plum is: 674e 2. How to convert 674e into Chinese characters? Use\ u ex: var str= "\ u674e"; console.log (str); / / the result is the range of Unicode codes of "Li" characters:\ u4e003\ u9fa5 3. Special characters need to escape characters\ n: newline\ t: tabs (indented)\ ":"\':'\\:\ 3.Boolean type Boolean function: the result value that represents true or false in the program: true or false var isBig=true; var isRun=false When participating in mathematical operations, true can do operations as 1 and false as 0. Var res=25+true; / / the result is a 26 4.Undefined type function: indicates that the data used does not exist. The Undefined type has only one value, that is, undefined. When the declared variable is not assigned (uninitialized), the default value of the variable is the undefined.5.Null type null used to represent an object that does not exist. The Null type has only one value, null, and if the function or method returns an object and cannot find the object, it returns null. 5.2 conversion of data types 1. Implicit (automatic) conversion of different types of data automatically converts 1. Number + string: convert the number to the string var num=15;var str= "Hello"; var res=num+str; / / result: 15Hello 2. Number + Boolean: convert Boolean to digital true=1,false=0 var num1=10;var isSun=true;var res1=num1+isSun;// result: 11 3. String + Boolean: converts a Boolean to the string var str1= "Hello"; var isSun1=true;var res2=str1+isSun1;// result: Hellotrue 4. Boolean + Boolean: convert Boolean to numeric true=1,false=0; var isSun2=true;var isSun3=flase;var res=isSun2+isSun3;// result 12. Cast-conversion function 1.toString () converts any type of data to string syntax: var num= variable .toString (); ex: var num=15; var str=num.toString (); console.log (typeof (str)); 2.parseInt () converts any type of data to an integer if the conversion is unsuccessful, the result is NaN (Not a Number) syntax: var result=parseInt (data) 3.parseFloat () converts any type of data to decimal if the conversion is not successful, the result is NaN syntax: var result=parseFloat (data); 4.Number () converts any type of data into Number type Note: if it contains illegal characters, it returns NaN syntax: var result=Number (data); 6. Operators and expressions

1. What is an expression?

An expression is an expression that consists of operators concatenating operands. Ex: 15: 20 var x=y=40 any expression will have a result.

two。 Operator

1. Arithmetic operators +, -, *, /,%, +,-5% 2x1; + +: self-incrementing operation, only do + 1 operation + + first: first self-increment, then operation; + + later: first operation, then self-increment Ex: var num=5;console.log (num++); / / print 5, change to 6console.log (+ + num); / / change to 7, print 7ex: var num=5; 5 (6) 6 6 (7) (8) 8 var res=num+ + + num+ num++ + + num+ num++ + num; 8 (9) 9. Relational operator (comparison) >, =, "10" result: both ends of the false relational operator, as long as one is number, the other will be implicitly converted to number type, and then compared. 2. "5" > "10" result: true "5" .charCodeAt (); / 53 "1" .charCodeAt (); / 49 "Zhang Sanfeng" > "Zhang Wuji" result: false 19977 > 260803. "3a" > 10 result: false Number ("3a")-- > NaN Note: when NaN is compared with any data, the result is false. Console.log ("3a" > 10); false console.log ("3a" = = 10); false console.log ("3a", =

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report