当前位置: 首页 > article >正文

JAVAweb-JS基本数据类型,变量,DOM,pop,push函数,事件

JavaScript,可以嵌套在静态页面中添加一些动态语言.

JavaScript是开发web脚本语言,但也被用到了很多非浏览器环境中,比如node平台

JS可以嵌套在静态页面中可以给静态页面添加一些动态效果(脚本语言),不同浏览器厂商(在浏览器中都有内置解析器解析JS语法)

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    //警告框
    alert("hello world");
   //提示框
   prompt("姑娘你的名字");
   prompt("姑娘你的年龄",18);
</script>
<script>
    console.log("hello world");
    console.log(123);
    console.log(undefined);
    console.log(null);
    console.log(typeof 123);
</script>

 

 

 

<script>
    var num;
    num=3;
    console.log(num);
    var a=100;
    var b=200;
    var c=300;
    console.log(a,b,c);
</script>

 

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function fun(){
        console.log("白毛浮绿水");
        console.log("红掌拨清波");
    }
    fun();
    function sum(a,b){
        console.log(a+b);
    }
    sum(100,200);
    sum("大华","小华");
</script>

 JS函数当中没有重载的问题,永远是后者覆盖前者.

 return后面的语句不再执行

return可以在函数体汇总将计算完结果返回,在函数体中使用

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function fun(){
        console.log("白毛浮绿水");
        console.log("红掌拨清波");
    }
    fun();
    function sum(a,b){
        console.log(a+b);
    }
    sum(100,200);
    sum("大华","小华");
    
</script>

pop:是数组的一个方法,主要的作用是可以在数组尾巴处移除一项元素,

pop方法有返回数值,返回的是移除掉的那项元素.

push:是数组方法,主要的作用是可以向数组添加一个或多个元素.

reverse:数组元素进行倒置

 

 

 indexof

 join,concat

 

 slice切割数组

 

 splice

 Dom

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    console.log(document);
    console.log(document.documentElement);
    console.log(document.head);
    console.log(document.body);
    console.log(document.title);
</script>

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        我是表单元素:<input type="text" value="我是表单元素" id="cur">
        <a href="http:\\www.baidu.com" id="box">我是超链接</a>
    </div>
</body>
</html>
<script>
    var cur = document.getElementById('cur');
    console.log(cur);
    console.log(cur.value);
    cur.value = '我是修改后的表单元素';
    var box=document.getElementById('box');
    console.log(box.innerHTML);
    box.innerHTML = '我是修改后的超链接';
</script>

 事件:事件是由用户触发


http://www.kler.cn/a/559749.html

相关文章:

  • 基于计算机视觉的手势识别:让机器理解我们的手势语言
  • DeepSeek安装部署笔记(一)
  • VMware中安装的ubuntu虚拟机屏幕由居中设置为最大化
  • 人工智能(AI):科技新纪元的领航者
  • 《解锁光量子制备:开启量子科技新时代》:此文为AI自动生成
  • HttpWatch 9.4.17 Pro网页调试与性能优化 资源工具分享
  • 前端循环全解析:JS/ES/TS 循环写法与实战示例
  • element ui 组件el-autocomplete的使用方法(输入建议,利用filter和include)
  • 常见的服务CPU过高Arthas快速排查问题详细笔记
  • (二)趣学设计模式 之 工厂方法模式!
  • 【从0做项目】Java音缘心动(1)———项目介绍设计
  • (未完)BCNet: Learning Body and Cloth Shape from A Single Image
  • 亲测Win11电脑可以安装LabVIEW的版本,及2015、2018、2020版本直接的区别
  • 第二周补充:Go语言中取地址符与fmt函数详解
  • 跟着李沐老师学习深度学习(十四)
  • 记浙江大华校招Java面试
  • DDD - 整洁架构
  • 代码随想录刷题day29|(栈与队列篇:队列)225.用队列实现栈
  • dockerfile构建haproxy
  • 【SpringMVC】概述 SSM:Spring + SpringMVC + Mybats