首页 > 其他分享 >web杂记(7)-js(3)

web杂记(7)-js(3)

时间:2023-08-23 11:24:30浏览次数:37  
标签:11 web 12 return function js 杂记 toJSON

目录

toJSON

b = {
  x: 11,
  y: 12,

  valueOf: function() {
    return Math.sqrt(this.x ** 2 + this.y ** 2);
  },
  toJSON: function() {
    return `{x:${this.x},y:${this.y},z:${Math.sqrt(this.x ** 2 + this.y ** 2)}}`;
  }
};
console.log(b.toJSON());
console.log(JSON.stringify(b));

b = {
  x: 11,
  y: 12,

  valueOf: function() {…
{x:11,y:12,z:16.278820596099706} debugger eval code:12:9
"{x:11,y:12,z:16.278820596099706}"

标签:11,web,12,return,function,js,杂记,toJSON
From: https://www.cnblogs.com/waterruby/p/17650605.html

相关文章

  • WebRTC 支持H265探索之路
    截至目前为止,参考了大量的文献和博客,都通过datachannel进行码流的传输,然后在浏览器端重新实现解码和渲染,因此意味着WebRTC不再具有任何的研究价值,还不如自身实现通过websocket对码流的传输,相比WebRTC庞大的体量,暂时不会做任何的调整。相信在专利面前,Google不会做任何的改善,还有UDP......
  • 2023-08-23 vuetifyjs icon用法 ==》 前缀mdi-加上icon名称
    我现在用的是最新3.0版本的vuetifyjs,它的icon库来自......
  • webman:配置端口/日志等(v1.5.7)
     一,文档地址:https://www.workerman.net/doc/webman/others/security.htmlhttps://www.workerman.net/doc/webman/request.htmlhttps://www.workerman.net/doc/webman/config.html说明:刘宏缔的架构森林—专注it技术的博客,网站:https://blog.imgtouch.com原文: https://b......
  • webman:全局中间件:记录访问日志(v1.5.7)
    一,官方文档地址:https://www.workerman.net/doc/webman/middleware.html二,php代码1,配置中间件:config/middleware.php12345678910111213141516171819<?php/** *Thisfileispartofwebman. * *LicensedunderTheMITLicense......
  • webman:用thinkorm访问数据库(v1.5.7)
    一,官方文档地址:https://www.workerman.net/doc/webman/db/thinkorm.html二,安装组件liuhongdi@lhdpc:/data/webman/imageadmin$composerrequire-Wwebman/think-orm./composer.jsonhasbeenupdatedRunningcomposerupdatewebman/think-orm--with-all-dependencies......
  • webman:用thinkcache访问redis(v1.5.7)
    一,官方文档地址:https://www.workerman.net/doc/webman/db/thinkcache.html二,安装组件liuhongdi@lhdpc:/data/webman/imageadmin$composerrequire-Wwebman/think-cache三,配置redisconfig/thinkcache.php,按自己的实际情况配置12345678910111213......
  • js 异步改成同步Promise
    functionPromise(executor){letself=this;if(typeofexecutor!=='function')thrownewTypeError('Promiseresolver'+executor+'isnotafunction');if(!(selfinstanceofPromise))thrownewTypeError(�......
  • JS中的JSON.Stringify 方法详解
    JSON.stringify是JavaScript中的一个方法,用于将JavaScript对象转换为JSON字符串。语法:JSON.stringify(value,replacer,space)参数说明:value:要转换为JSON字符串的值。replacer(可选):用于过滤和转换结果的函数或数组。如果是函数,则只转换函数返回的结果;如果是数组,则......
  • webman:配置异常处理返回json格式(v1.5.7)
    一,添加一个除0错的异常代码:页面显示效果如图:二,配置:php代码1,config/123456789101112131415161718<?php/** *Thisfileispartofwebman. * *LicensedunderTheMITLicense *Forfullcopyrightandlicenseinformation......
  • webbrowser显示xml, xml通过xslt转xhtml
    为WebBrowser控件增加显示XML文档接口(c#)ShowXMLinWebBrowsercontrol https://learn.microsoft.com/en-us/answers/questions/1181957/show-xml-in-webbrowser-controlViewXMLFilesEasilywithXmlGridViewControlhttps://www.codeproject.com/articles/16497/view-xml......