Hey everyone! I've got some great news for all you beginners learning JavaScript! A quick reference guide for JavaScript is now available! You can easily check important concepts, functions, and methods right away. For more details about the guide, check it out here.
What's in the Quick Reference Guide
Console
// => Hello world! console.log("Hello world!"); // => Hello CheatSheets.zip console.warn("hello %s", "CheatSheets.zip"); // Output error message to standard error console.error(new Error("Oops!"));
Numbers
let amount = 6; let price = 4.99;
Variables
let x = null; let name = "Tammy"; const found = false; // => Tammy, false, null console.log(name, found, x); var a; console.log(a); // => undefined
Strings
let single = "Wheres my bandit hat?"; let double = "Wheres my bandit hat?"; // => 21 console.log(single.length);
Arithmetic Operators
5 + 5 = 10 // Addition 10 - 5 = 5 // Subtraction 5 * 10 = 50 // Multiplication 10 / 5 = 2 // Division 10 % 5 = 0 // Modulus
Comments
// This is a comment /* You need to change this setting before deployment. */
Assignment Operators
let number = 100; // Both statements add 10 number = number + 10; number += 10; console.log(number); // => 120
String Interpolation
let age = 7; // String concatenation "Tommy is " + age + " years old."; // String interpolation `Tommy is ${age} years old.`;
Conditional Statements
const isMailSent = true; if (isMailSent) { console.log("Mail sent to recipient"); }
Ternary Operator
var x = 1; // => true result = x == 1 ? true : false;
Logical Operators
true || false; // true 10 > 5 || 10 > 20; // true false || false; // false 10 > 100 || 10 > 20; // false
Comparison Operators
1 > 3; // false 3 > 1; // true 250 >= 250; // true 1 === 1; // true 1 === 2; // false 1 === "1"; // false
Arrays
const fruits = ["apple", "orange", "banana"]; // Different data types const data = [1, "chicken", false];
Objects
const apple = { color: "Green", price: { bulk: "$3/kg", smallQty: "$4/kg" }, }; console.log(apple.color); // => Green console.log(apple.price.bulk); // => $3/kg
Classes
class Dog { constructor(name) { this._name = name; } introduce() { console.log("This is " + this._name + " !"); } // Static method static bark() { console.log("Woof!"); } } const myDog = new Dog("Buster"); myDog.introduce(); // Calling static method Dog.bark();
Modules
// myMath.js // Default export export default function add(x, y) { return x + y; } // Named export export function subtract(x, y) { return x - y; } // Multiple exports function multiply(x, y) { return x * y; } function duplicate(x) { return x * 2; } export { multiply, duplicate };
Asynchronous Processing
function helloWorld() { return new Promise((resolve) => { setTimeout(() => { resolve("Hello World!"); }, 2000); }); } async function msg() { const msg = await helloWorld(); console.log("Message:", msg); } msg(); // Message: Hello World! <p>This quick reference guide covers a wide range of topics from the basics to more advanced JavaScript concepts. Be sure to download it here and make it a handy tool for your coding journey!</p>
以上是JavaScript 备忘单的详细内容。更多信息请关注PHP中文网其他相关文章!

JavaScript字符串替换方法详解及常见问题解答 本文将探讨两种在JavaScript中替换字符串字符的方法:在JavaScript代码内部替换和在网页HTML内部替换。 在JavaScript代码内部替换字符串 最直接的方法是使用replace()方法: str = str.replace("find","replace"); 该方法仅替换第一个匹配项。要替换所有匹配项,需使用正则表达式并添加全局标志g: str = str.replace(/fi

简单JavaScript函数用于检查日期是否有效。 function isValidDate(s) { var bits = s.split('/'); var d = new Date(bits[2] '/' bits[1] '/' bits[0]); return !!(d && (d.getMonth() 1) == bits[1] && d.getDate() == Number(bits[0])); } //测试 var

本文探讨如何使用 jQuery 获取和设置 DOM 元素的内边距和外边距值,特别是元素外边距和内边距的具体位置。虽然可以使用 CSS 设置元素的内边距和外边距,但获取准确的值可能会比较棘手。 // 设置 $("div.header").css("margin","10px"); $("div.header").css("padding","10px"); 你可能会认为这段代码很

本文探讨了十个特殊的jQuery选项卡和手风琴。 选项卡和手风琴之间的关键区别在于其内容面板的显示和隐藏方式。让我们深入研究这十个示例。 相关文章:10个jQuery选项卡插件

发现十个杰出的jQuery插件,以提升您的网站的活力和视觉吸引力!这个精选的收藏品提供了不同的功能,从图像动画到交互式画廊。让我们探索这些强大的工具: 相关文章: 1

HTTP-Console是一个节点模块,可为您提供用于执行HTTP命令的命令行接口。不管您是否针对Web服务器,Web Serv

本教程向您展示了如何将自定义的Google搜索API集成到您的博客或网站中,提供了比标准WordPress主题搜索功能更精致的搜索体验。 令人惊讶的是简单!您将能够将搜索限制为Y

当div内容超出容器元素区域时,以下jQuery代码片段可用于添加滚动条。 (无演示,请直接复制到Firebug中) //D = document //W = window //$ = jQuery var contentArea = $(this), wintop = contentArea.scrollTop(), docheight = $(D).height(), winheight = $(W).height(), divheight = $('#c


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

Atom编辑器mac版下载
最流行的的开源编辑器

Dreamweaver Mac版
视觉化网页开发工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。