前端学习5——js

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS</title>
</head>
<body>
    <button onclick="alert('hello world');">按钮 点我</button>
    <pre>
        <font size="5">
    随堂笔记:
        p13 js学习内容介绍  
            没啥记的  大致过一遍
        p14 js的基本使用
            面向对象 解释型 客户端脚本语言
            组成: ECMAscript DOM BOM
            控制台 console
            行内(耦合度高) 内部 外部(src引入文件 双标签内写无效)
            script建议放在body的最后
            alert少用 不点确定 不会继续
        p15 js的基本语法
            表达式不许加分号
            一行一句  或加分号 (建议加分号)
            命名规范 避开关键字 
        p16 js的基本语法-变量
            js弱类型语言
            可同时声明多个变量 未赋值 undefined
            变量提升  声明前(代码也可使用) undefined
        p17 js的基本语法-数据类型
            数值、布尔、字符串
            undefined 值不存在:1.只声明不赋值 2.需形参不传实参 3.函数无返回值,接收值为undefined
            null 空值 注意点:1.typeof操作符测试null返回object字符串 2.undefined派生于null,等值比较返回true
            对象(object)【各种值的集合】 包含 数组、函数
        p18、19 js的基本语法-类型转换
            自动类型转换 有值为true   非空数值型字符串为1 空值为0
            函数转换 自动截断 parseInt()字符串转int parseFloat() (要求前面满足)否则NaN
            NaN(NotaNumber,非数)是计算机科学中数值数据类型的一类值,表示未定义或不可表示的值。
            显示转换   后缀
               .toString()将值转换为字符串  
               .toFixed()保留指定小数位  不是简单的四舍五入
               不能为null
            转字符串  String 可以转换null
    </font></pre>
    <script type="text/javascript">
        // alert("这是个按钮 内部")
    </script>
    <script src="js/js5.js">
        //引入后 <> <>内部将无效
    </script>
</body>
</html>

js文件部分

// alert("外部引入")
console.log("写到控制台");
a=2
console.log(a);//测试 提升
var b=1
console.log(b);
var flag=true
var a="hello world"
console.log(flag)//
console.log(a)//字符串 黑色

function strprint(str1){
    console.log(str1)
}
strprint("hello str")
var nothing;
console.log(nothing==null)
console.log(null+" "+typeof(null))
//字符串之间 也可用, (显示为空格)
console.log(parseInt("123.45"))
var aa=1.3451
console.log(aa.toFixed(2))


版权声明:本文为m0_60633517原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。