[front end] javascript learning notes (I) — quick start

Time:2022-5-11

✨JavaScript

JavaScript (JS for short) is aFunction first lightweightInterpretive or just in time compilationProgramming language. Although it is developed asWebPagescripting language But it is also used in many non browser environments. JavaScript is based on prototype programming, multi paradigm dynamic scripting language, and supportsobject-orientedImperativeDeclarativeFunctional programming paradigm

✨ Course link

[crazy God says Java] the latest JavaScript tutorial is easy to understand_ Beep beep beep_ bilibili

✨ Study notes

First JavaScript

Title
alert("Hello World!");

Basic grammar

Title


    
        // 1.  Define variables
        var score = 71;
        // 2.  Control conditions
        if(score > 60 && score < 70){
            alert("60 ~ 70")
        }else if(score > 70 && score < 80){
            alert("70 ~ 80")
        }else {
            alert("other")
        }

        //Semicolon optional

        /**
         *Notes
         */

        //Print variables in the browser console
        // console.log(score)

Data type quick browse

variable

var

number

JS does not distinguish between decimal and integer

NaN:not a nuber

Infinity: Infinity

character string

Boolean

Logical operation

Comparison operator

  • =Assignment
  • ==Equal to (if the type is different and the value is the same, it will be judged as true)
  • ===Absolutely equal to (the same type, the same value, and the result is true)

(this is a JS defect. Insist not to use = = comparison)

NaN

  • Nan = Nan, which is not equal to all values, including yourself
  • You can only judge whether this number is Nan by IsNaN (Nan)

Floating point problem

console.log((1/3) === (1 - 2/3))

Try to avoid using floating-point numbers for operation, which has accuracy problems!

Null and undefined

  • Null null
  • Undefined undefined

array

Java values must be objects of the same type, which is not required in JS!

//To ensure the readability of the code, try to use []
var arr = [1,2,3,4,5,'Hello',null,true];
new Array(1,12,3,4,4,5,'Hello');

If the array subscript is out of boundsundefined

object

Objects are braces and arrays are brackets

Each attribute is separated by a comma, and the last one does not need to be added

var Person = {
    name: "Test",
    age: 3,
    tags: ['js', 'Java', 'php']
}

Get the value of the object

Person.name
> "Test"
Person.age
> 3

Strict inspection mode

Title







    
        'use strict';
        //Global variable
        var i = 1;
        // ES6 let

⭐ Please indicate the source for reprint

Author: Double concentrated furuibai

Original link:https://www.cnblogs.com/Flat-White/p/14987702.html

All rights reserved. If you need to reprint, please indicate the source.

Recommended Today

Using genetic algorithm for intelligent course scheduling, I believe teachers will like it very much

Summary:Genetic algorithm is an AI model that simulates biological evolution based on natural selection process. It can search the optimal solution generation by generation in the simulated biological evolution process. This paper uses genetic algorithm to realize a simple program to schedule the course. This article is shared from Huawei cloud community《How to use genetic […]