zoukankan      html  css  js  c++  java
  • JS基础——脚本位置、数据类型、函数作用域

    (一)脚本位置

    JavaScript是嵌套到浏览器里的脚本语言;可放在3个位置:

    1、写在头部(head里)

    <head>
        <meta charset="UTF-8">
        <title>标题</title>
        <script type="text/javascript">
            alert('hello world');
        </script>
    </head>

    2、写在body体里(或内嵌到html标签里)

    <body>
        <a href="javascript:alert('hello')">点击</a>
        <script type="text/javascript">
            alert('hello world');
        </script>
    </body>

    3、写到外部的js文件

        <script type="text/javascript" src="common.js"></script>

    (二)js的数据类型

    1、字符串 string

    2、数值 number

    3、布尔类型 boolean

    4、函数  function

    5、null

    6、undefined

    7、数组 object

    (三)函数的特殊说明

    1、全局作用域

      在函数外部定义的变量,或者在函数内部定义的变量(不带var),均是全局变量;

    2、局部作用域

      在函数内部定义的变量(带var),是局部变量;只能在函数内部有效;

  • 相关阅读:
    Explain执行计划
    SQL优化(SQL + 索引)
    SQL(含索引)
    分组聚合 merger
    服务分组 group
    多注册中心 registry
    多协议 protocol
    常用协议 —— webservice://
    常用协议 —— http://
    最强AngularJS资源合集
  • 原文地址:https://www.cnblogs.com/adair/p/6970648.html
Copyright © 2011-2022 走看看