首页 > 其他分享 >mordenjs1 basic

mordenjs1 basic

时间:2024-05-17 19:57:09浏览次数:13  
标签:undefined mordenjs1 number alert let typeof basic Hello

导入js代码

<script type="text/javascript"><!--
    ...
//--></script>


<script src="/path/to/script.js"></script>

使用严格模式 "use strict";

变量

三种命名方式 let,const,var

var

  • 没有块级作用域
  • 可以重新声明

number

number: 整数,浮点数,Infinity:无限大 和 NaN : 计算错误。

NaN 和任何东西计算都是 NaN

BigInt 类型

// 尾部的 "n" 表示这是一个 BigInt 类型
const bigInt = 1234567890123456789012345678901234567890n;

string

在 JavaScript 中,有三种包含字符串的方式。

  1. 双引号:"Hello".
  2. 单引号:'Hello'.
  3. 反引号:`Hello`.

双引号和单引号都是“简单”引用,在 JavaScript 中两者几乎没有什么差别。

反引号是 功能扩展 引号。它们允许我们通过将变量和表达式包装在 ${…} 中,来将它们嵌入到字符串中。

let name = "John";

// 嵌入一个变量
alert( `Hello, ${name}!` ); // Hello, John!

// 嵌入一个表达式
alert( `the result is ${1 + 2}` ); // the result is 3

Boolean

null

undefined

如果一个变量已被声明,但未被赋值,那么它的值就是 undefined

let age;

alert(age); // 弹出 "undefined"

Object and Symbol

object 则用于储存数据集合和更复杂的实体。
symbol 类型用于创建对象的唯一标识符。

typeof 返回数据类型

typeof undefined // "undefined"

typeof 0 // "number"

typeof 10n // "bigint"

typeof true // "boolean"

typeof "foo" // "string"

typeof Symbol("id") // "symbol"

typeof Math // "object"  (1)

typeof null // "object"  (2)

typeof alert // "function"  (3)

交互 alert , prompt and confirm

alert("Hello");
// 显示一个带有文本消息的模态窗口,还有 input 框和确定/取消按钮
let result = prompt(title, [default]);
// 显示一个带有 `question` 以及确定和取消两个按钮的模态窗口
let result = confirm(question);

类型转化

字符串 : value = String(value);
数字 and boolean:

在算术函数和表达式中,会自动进行 number 类型转换。

alert( "6" / "2" ); // 3, string 类型的值被自动转换成 number 类型后进行计算
let num = Number(str); // 变成 number 类型 123
Boolean("hello")

https://zh.javascript.info/operators

标签:undefined,mordenjs1,number,alert,let,typeof,basic,Hello
From: https://www.cnblogs.com/bigsharker/p/18198521

相关文章

  • HTML 03 - Basic Tags
    HTML-BasicTags HTMLtagsarethefundamentalelementsofHTMLusedfordefiningthestructureofthedocument.Thesearelettersorwordsenclosedbyanglebrackets(<and>).Usually,mostoftheHTMLtagscontainsanOpeningandaClosingtag......
  • "Bios"是计算机系统中的基本输入输出系统(Basic Input/Output System),负责在计算机启动
    "Bios"是计算机系统中的基本输入输出系统(BasicInput/OutputSystem),负责在计算机启动时初始化硬件设备、检测系统资源,并启动操作系统。Bios开发人员是负责设计、开发和维护计算机系统的Bios软件的专业人员。工作内容:软件设计和开发:Bios开发人员负责设计和编写Bios软件,包......
  • Windows Basics - Finding Files on Your Computer Back to Tutorial
     everything 推荐用这个工具搜索文件 FindingfilesonyourcomputerInthepreviouslesson,wetalkedabouthowfolderscanhelptokeepyourfilesorganized.However,theremaybetimeswhenyouhavetroublefindingacertainfile.Ifthishappenstoyou......
  • Windows Basics - Common Computer Tasks
    CommoncomputertasksLearninghowtouseacomputercanfeeloverwhelmingattimes.Fortunately,therearesomecommoncomputerskillsthatwillworkthesamewayinalmostanysituation.Onceyoulearnhowtousetheseskills,you'llbeabletouse......
  • Windows Basics - Adjusting Your Settings
     AdjustingyoursettingsAtsomepoint,youmaywanttoadjustyourcomputer'ssettings.Forexample,youmightwanttochangeyourdesktopbackgroundormodifyyourInternetsettings.YoucanchangethesesettingsandmorefromtheControlPanel控制......
  • Windows Basics - Working with Files
     WorkingwithfilesUnderstandinghowtoworkwithfilesandfoldersisanimportantpartofusingyourcomputer.Onceyouunderstandhowfilesandfolderwork,you'llusethemallthetime.Inthislesson,we'llshowyoutheabsolutebasicsof......
  • Windows Basics - Navigating Windows
     NavigatingWindowsWhetheryou'renewtocomputersorjustWindows,it'simportanttolearnthebasicsofusingyourcomputer.Ifitallseemsalittleoverwhelmingrightnow,don'tworry!We'lltakeyouthroughitstepbystepands......
  • Fastjson反序列化漏洞2:BasicDataSource利用链-用于内网
    之前说的Fastjson的利用链,补充来了,没有偷懒(狗头)前情提要:BCEL:加载恶意类、Fastjson反序列化漏洞1:吹吹水Fastjson干了啥Fastjson就是处理json用的,可以将json转换成对象(自定义的一套序列化和反序列化)举个例子:下面这个json字符串经过JSON.parse(jsonString)处理可以得到com.test......
  • 面向对象编程(basic)
    面向对象内容的三条主线:Java类及类的成员:(重点)属性、方法、构造器;(熟悉)代码块、内部类面向对象的特征:封装、继承、多态、(抽象)其他关键字的使用:this、super、package、import、static、final、interface、abstract等1.面向对象VS面向过程面向过程思想线性思维步......
  • Computer Basics - Top 10 keyboard shortcuts everyone should know
    REFhttps://www.computerhope.com/tips/tip79.htmTop10keyboardshortcuts(快捷键)everyoneshouldknowUsingkeyboardshortcutscangreatlyincreaseyourproductivity,reducerepetitivestrain,andhelpkeepyoufocused.Forexample,tocopytext,youcanhi......