javascript运算符_使用JavaScript中的示例删除运算符

news/2024/7/19 16:32:26 标签: javascript, css, js, zookeeper, web

javascript运算符

JavaScript删除运算符 (JavaScript delete Operator)

"delete" is an operator in JavaScript and it is used to delete a property of an object. After deleting the particular property, that property will not be accessible and returns "undefined".

“删除”是JavaScript中的运算符,用于删除对象的属性。 删除特定属性后,该属性将不可访问并返回“ undefined”

Syntax:

句法:

delete property;

Example:

例:

<html>
<head>
<title>JavaScipt Example</title>
</head>

<body>
	<script>		
		var employee = {
			name: "Amit shukla",
			age: 21,
			city: "Gwalior",
			Country: "India"
		};
		
		//printing the object
		document.write("Printing employee details...<br>");
		document.write("Name: " + employee.name + "<br/>");
		document.write("Age: " + employee.age + "<br/>");
		document.write("City: " + employee.city + "<br/>");
		document.write("Country: " + employee.Country + "<br/>");
		document.write("<br>");
		
		//deleting properties age & city
		delete employee.age;
		delete employee.city;

		document.write("Printing employee details after delete...<br>");
		document.write("Name: " + employee.name + "<br/>");
		document.write("Age: " + employee.age + "<br/>");
		document.write("City: " + employee.city + "<br/>");
		document.write("Country: " + employee.Country + "<br/>");		
	</script>
</body>
</html>

Output

输出量

Printing employee details...
Name: Amit shukla
Age: 21
City: Gwalior
Country: India

Printing employee details after delete...
Name: Amit shukla
Age: undefined
City: undefined
Country: India


翻译自: https://www.includehelp.com/code-snippets/delete-operator-with-example-in-javascript.aspx

javascript运算符


http://www.niftyadmin.cn/n/1255750.html

相关文章

Python进阶(二)

高阶函数 1.把函数作为参数传入&#xff0c;这样的函数称为高阶函数&#xff0c;函数式编程就是指这种高度抽象的编程范式。 2.Python内建了map( )和reduce( ) 函数 map()函数接收两个参数&#xff0c;一个是函数&#xff0c;一个是Iterable&#xff0c;map将传入的函数依次作用…

as_hash ruby_Hash.merge!(other_hash)方法与Ruby中的示例

as_hash rubyHash.merge&#xff01;(other_hash)方法 (Hash.merge!(other_hash) Method) In this article, we will study about Hash.merge!(other_hash) Method. The working of the method can’t be assumed because it’s quite a different name. Let us read its defin…

2018 计蒜之道 初赛 第二场

签到完看到C没什么人过就溜乐。 A.淘宝的推荐系统 直接DP&#xff0c;时间复杂度$O(∑nd)$ #include <bits/stdc.h>using namespace std;#define rep(i, a, b) for (int i(a); i < (b); i) #define dec(i, a, b) for (int i(a); i > (b); --i) #define MP make_pa…

在Python中创建目录并处理异常

Python os.mkdir()方法 (Python os.mkdir() method) The built-in, os module is useful in creating directories. The syntax to create the directory is, 内置的“ os”模块可用于创建目录 。 创建目录的语法为 &#xff0c; os.mkdir(<path>)Python code to create…

类似jQuery的原生JS封装的ajax方法

一&#xff0c;前言&#xff1a; 前文&#xff0c;我们介绍了ajax的原理和核心内容&#xff0c;主要讲的是ajax从前端到后端的数据传递的整个过程。 Ajax工作原理和原生JS的ajax封装 真正的核心就是这段代码&#xff1a; var xhr new XMLHTTPRequest(); xhr.open("method…

Python线程模块| setprofile()方法与示例

Python threading.setprofile()方法 (Python threading.setprofile() Method) setprofile() is an inbuilt method of the threading module in Python. It is used to set a profile function for all the threads that are created by the threading module. The func functi…

线性代数矩阵转置乘法_单位矩阵转置属性| 使用Python的线性代数

线性代数矩阵转置乘法Prerequisites: 先决条件&#xff1a; Defining a matrix 定义矩阵 Identity matrix 身份矩阵 Transpose matrix 转置矩阵 In linear algebra, the identity matrix, of size n is the n n square matrix with ones on the main diagonal and zeros else…

在mac上面运行cherrytree

下载源码包 wget http://www.giuspen.com/software/cherrytree-0.38.4.tar.xz解压 tar -xvf cherrytree-0.38.4.tar.xz 安装依赖brew install pygtkbrew install gtk-mac-integration brew install pygtksourceview brew install dbus brew install dbus-glib pip install dubs…