2021/11/2 Js对象

number 数值  整数和小数
string  字符串  (字符)   ""  ''
bool    true/false
null    没有
undefined  
symbol es6
 
 
object: 正则、数组     字面量(json对象)
function


json xml
序列化  反序列化
JSON.stringify()
JSON.parse()
 
 
var a=10;
{
    a=20;
 }
     {}                      括号加不加没有用处
console.log(a);
 
 
 运算符: + - * /
只有+号是 数值链接  或者作为运算符
计算机是二级制位的所以要先转换为整数再进行计算 js里面没有余数的说法
   =  ==      ===                               一个等于赋值   两个等于只看值    三个等于 看类型和值 
 
parseInt   取整  81.5    81   // 这个取整不是四舍五入
parseFloat
isNaN    Not a number
 
arguments   参数数组  
它是个伪数组 可以当数组使用 没有下标               
 
 
arr.shift()   头部删除
arr.unshift()  头部添加
arr.push()    尾部添加
arr.pop()  尾部删除 
 
arr.push(2)
console.log(arr)
splice 第一个代表开始位置    第二个代表删除个数    第三个代表添加数据
 
 
点击事件的四种方法:
<!-- 第一种 -->
 <div class="div" onclick="alert(0)">
        点我
    </div> 
 <!-- 第二种 -->
<div class="div">
        点我
   </div>
 
<script>
        window.onload=function(){
            var div=document.querySelector(".div");
            div.onclick=function(){
                alert(1);
            }
        }
    </script>
  <!-- 第三种 -->
 <script src=".01js.js"></script>   链接到一个js文件
 
window.onload=function(){
    var div=document.querySelector(".div");
    div.onclick=function(){
        alert(1);
    }
}
 
    <!-- 第四种    点击事件方式 -->
    <a href="javascript.void(0)">空连接</a>      空连接不做跳转
posted on 2021-11-02 17:29  闲鱼仔  阅读(40)  评论(0)    收藏  举报