--- title: Notification.data slug: Web/API/notification/data translation_of: Web/API/Notification/data ---
{{APIRef("Web Notifications")}}
data
只读属性是 {{domxref("Notification")}} 的接口,当它作为构造函数的option可选项之一时,返回结构化的Notification的data数据。
当你创建Notification时,notification使用的数据可以使任意类型。
{{AvailableInWorkers}}
附加语法糖:关于克隆对象的速度研究。
https://dassur.ma/things/deep-copy/
博客作者认为目前(参考)最快的object克隆、复制方式。
function structuralClone(obj) {
return new Notification('', {data: obj, silent: true}).data;
}
var data = Notification.data;
结构化的克隆数据
产生一个 notification; 简单的options
作为构造参数, 将会触发以option为构造参数的 Notification()
.
var options = { body: 'Do you like my body?', data: 'I like peas.' } var n = new Notification('Test notification',options); n.data // should return 'I like peas.'
Specification | Status | Comment |
---|---|---|
{{SpecName('Web Notifications','#dom-notification-data','data')}} | {{Spec2('Web Notifications')}} | Living standard |