前端JavaScript規范


摘要:?JavaScript規范 目錄 類型 對象 數組 字符串 函數 屬性 變量 條件表達式和等號 塊 注釋 空白 逗號 分號 類型轉換 命名約定 存取器 構造器 事件 模塊 jQuery ES5 兼容性 HTML、CSS、JavaScript分離 使用jsHint 前端工具 類型 原始值: 相當于傳值(JavaScript對象都提供了字面量),使用字面量創建對象。

JavaScript規范

目錄

  1. 類型
  2. 對象
  3. 數組
  4. 字符串
  5. 函數
  6. 屬性
  7. 變量
  8. 條件表達式和等號
  9. 注釋
  10. 空白
  11. 逗號
  12. 分號
  13. 類型轉換
  14. 命名約定
  15. 存取器
  16. 構造器
  17. 事件
  18. 模塊
  19. jQuery
  20. ES5 兼容性
  21. HTML、CSS、JavaScript分離
  22. 使用jsHint
  23. 前端工具

類型

  • 原始值: 相當于傳值(JavaScript對象都提供了字面量),使用字面量創建對象。

    • string
    • number
    • boolean
    • null
    • undefined
    var foo = 1, bar = foo; bar = 9; console.log(foo, bar); // => 1, 9
  • 復雜類型: 相當于傳引用

    • object
    • array
    • function
    var foo = [1, 2], bar = foo; bar[0] = 9; console.log(foo[0], bar[0]); // => 9, 9

對象

  • 使用字面值創建對象

    // bad
    var item = new Object(); // good var item = {};
  • 不要使用保留字?reserved words?作為鍵

    // bad
    var superman = { class: 'superhero', default: { clark: 'kent' }, private: true }; // good var superman = { klass: 'superhero', defaults: { clark: 'kent' }, hidden: true };

數組

  • 使用字面值創建數組

    // bad
    var items = new Array(); // good var items = [];
  • 如果你不知道數組的長度,使用push

    var someStack = []; // bad someStack[someStack.length] = 'abracadabra'; // good someStack.push('abracadabra');
  • 當你需要拷貝數組時使用slice.?jsPerf

    var len = items.length, itemsCopy = [], i; // bad for (i = 0; i < len; i++) { itemsCopy[i] = items[i]; } // good itemsCopy = items.slice();
  • 使用slice將類數組的對象轉成數組.

    function trigger() { var args = [].slice.apply(arguments); ... }

字符串

  • 對字符串使用單引號?''(因為大多時候我們的字符串。特別html會出現")

    // bad
    var name = "Bob Parr"; // good var name = 'Bob Parr'; // bad var fullName = "Bob " + this.lastName; // good var fullName = 'Bob ' + this.lastName;
  • 超過80(也有規定140的,項目具體可制定)個字符的字符串應該使用字符串連接換行

  • 注: 如果過度使用,長字符串連接可能會對性能有影響.?jsPerf?&?Discussion

    // bad
    var errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.'; // bad var errorMessage = 'This is a super long error that \ was thrown because of Batman. \ When you stop to think about \ how Batman had anything to do \ with this, you would get nowhere \ fast.'; // good var errorMessage = 'This is a super long error that ' + 'was thrown because of Batman.' + 'When you stop to think about ' + 'how Batman had anything to do ' + 'with this, you would get nowhere ' + 'fast.';
  • 編程時使用join而不是字符串連接來構建字符串,特別是IE:?jsPerf.

    var items,messages, length, i; messages = [{ state: 'success', message: 'This one worked.' },{ state: 'success', message: 'This one worked as well.' },{ state: 'error', message: 'This one did not work.' }]; length = messages.length; // bad function inbox(messages) { items = '<ul>'; for (i = 0; i < length; i++) { items += '<li>' + messages[i].message + '</li>'; } return items + '</ul>'; } // good function inbox(messages) { items = []; for (i = 0; i < length; i++) { items[i] = messages[i].message; } return '<ul><li>' + items.join('</li><li>') + '</li></ul>'; }

函數

  • 函數表達式:

    // 匿名函數表達式
    var anonymous = function() { return true; }; // 有名函數表達式 var named = function named() { return true; }; // 立即調用函數表達式 (function() { console.log('Welcome to the Internet. Please follow me.'); })();
  • 絕對不要在一個非函數塊里聲明一個函數,把那個函數賦給一個變量。瀏覽器允許你這么做,但是它們解析不同。

  • 注:?ECMA-262定義把定義為一組語句,函數聲明不是一個語句。閱讀ECMA-262對這個問題的說明.

    // bad
    if (currentUser) { function test() { console.log('Nope.'); } } // good if (currentUser) { var test = function test() { console.log('Yup.'); }; }
  • 絕對不要把參數命名為?arguments, 這將會逾越函數作用域內傳過來的?arguments?對象.

    // bad
    function nope(name, options, arguments) { // ...stuff... } // good function yup(name, options, args) { // ...stuff... }

屬性

  • 當使用變量和特殊非法變量名時,訪問屬性時可以使用中括號(.?優先).

    var luke = { jedi: true, age: 28 }; function getProp(prop) { return luke[prop]; } var isJedi = getProp('jedi');

變量

  • 總是使用?var?來聲明變量,如果不這么做將導致產生全局變量,我們要避免污染全局命名空間。

    // bad
    superPower = new SuperPower(); // good var superPower = new SuperPower();
  • 使用一個?var?以及新行聲明多個變量,縮進4個空格。

    // bad
    var items = getItems(); var goSportsTeam = true; var dragonball = 'z'; // good var items = getItems(), goSportsTeam = true, dragonball = 'z';
  • 最后再聲明未賦值的變量,當你想引用之前已賦值變量的時候很有用。

    // bad
    var i, len, dragonball, items = getItems(), goSportsTeam = true; // bad var i, items = getItems(), dragonball, goSportsTeam = true, len; // good var items = getItems(), goSportsTeam = true, dragonball, length, i;
  • 在作用域頂部聲明變量,避免變量聲明和賦值引起的相關問題。

    // bad
    function() { test(); console.log('doing stuff..'); //..other stuff.. var name = getName(); if (name === 'test') { return false; } return name; } // good function() { var name = getName(); test(); console.log('doing stuff..'); //..other stuff.. if (name === 'test') { return false; } return name; } // bad function() { var name = getName(); if (!arguments.length) { return false; } return true; } // good function() { if (!arguments.length) { return false; } var name = getName(); return true; }

條件表達式和等號

  • 合理使用?===?和?!==?以及?==?和?!=.
  • 合理使用表達式邏輯操作運算.
  • 條件表達式的強制類型轉換遵循以下規則:

    • 對象?被計算為?true
    • Undefined?被計算為?false
    • Null?被計算為?false
    • 布爾值?被計算為?布爾的值
    • 數字?如果是?+0, -0, or NaN?被計算為?false?, 否則為?true
    • 字符串?如果是空字符串?''?則被計算為?false, 否則為?true
    if ([0]) { // true // An array is an object, objects evaluate to true }
  • 使用快捷方式.

    // bad
    if (name !== '') { // ...stuff... } // good if (name) { // ...stuff... } // bad if (collection.length > 0) { // ...stuff... } // good if (collection.length) { // ...stuff... }
  • 閱讀?Truth Equality and JavaScript?了解更多

  • 給所有多行的塊使用大括號

    // bad
    if (test) return false; // good if (test) return false; // good if (test) { return false; } // bad function() { return false; } // good function() { return false; }

注釋

  • 使用?/** ... */?進行多行注釋,包括描述,指定類型以及參數值和返回值

    // bad
    // make() returns a new element // based on the passed in tag name // // @param <String> tag // @return <Element> element function make(tag) { // ...stuff... return element; } // good /** * make() returns a new element * based on the passed in tag name * * @param <String> tag * @return <Element> element */ function make(tag) { // ...stuff... return element; }
  • 使用?//?進行單行注釋,在評論對象的上面進行單行注釋,注釋前放一個空行.

    // bad
    var active = true; // is current tab // good // is current tab var active = true; // bad function getType() { console.log('fetching type...'); // set the default type to 'no type' var type = this._type || 'no type'; return type; } // good function getType() { console.log('fetching type...'); // set the default type to 'no type' var type = this._type || 'no type'; return type; }
  • 如果你有一個問題需要重新來看一下或如果你建議一個需要被實現的解決方法的話需要在你的注釋前面加上?FIXME?或?TODO?幫助其他人迅速理解

    function Calculator() { // FIXME: shouldn't use a global here total = 0; return this; }
    function Calculator() { // TODO: total should be configurable by an options param this.total = 0; return this; }
  • 滿足規范的文檔,在需要文檔的時候,可以嘗試jsdoc.

空白

  • 縮進、格式化能幫助團隊更快得定位修復代碼BUG.
  • 將tab設為4個空格

    // bad
    function() { ??var name; } // bad function() { ?var name; } // good function() { ????var name; }
  • 大括號前放一個空格

    // bad
    function test(){ console.log('test'); } // good function test() { console.log('test'); } // bad dog.set('attr',{ age: '1 year', breed: 'Bernese Mountain Dog' }); // good dog.set('attr', { age: '1 year', breed: 'Bernese Mountain Dog' });
  • 在做長方法鏈時使用縮進.

    // bad
    $('#items').find('.selected').highlight().end().find('.open').updateCount(); // good $('#items') .find('.selected') .highlight() .end() .find('.open') .updateCount(); // bad var leds = stage.selectAll('.led').data(data).enter().append('svg:svg').class('led', true) .attr('width', (radius + margin) * 2).append('svg:g') .attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')') .call(tron.led); // good var leds = stage.selectAll('.led') .data(data) .enter().append('svg:svg') .class('led', true) .attr('width', (radius + margin) * 2) .append('svg:g') .attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')') .call(tron.led);

逗號

  • 不要將逗號放前面

    // bad
    var once , upon , aTime; // good var once, upon, aTime; // bad var hero = { firstName: 'Bob' , lastName: 'Parr' , heroName: 'Mr. Incredible' , superPower: 'strength' }; // good var hero = { firstName: 'Bob', lastName: 'Parr', heroName: 'Mr. Incredible', superPower: 'strength' };
  • 不要加多余的逗號,這可能會在IE下引起錯誤,同時如果多一個逗號某些ES3的實現會計算多數組的長度。

    // bad
    var hero = { firstName: 'Kevin', lastName: 'Flynn', }; var heroes = [ 'Batman', 'Superman', ]; // good var hero = { firstName: 'Kevin', lastName: 'Flynn' }; var heroes = [ 'Batman', 'Superman' ];

分號

  • 語句結束一定要加分號

    // bad
    (function() { var name = 'Skywalker' return name })() // good (function() { var name = 'Skywalker'; return name; })(); // good ;(function() { var name = 'Skywalker'; return name; })();

類型轉換

  • 在語句的開始執行類型轉換.
  • 字符串:

    //  => this.reviewScore = 9;// bad var totalScore = this.reviewScore + ''; // good var totalScore = '' + this.reviewScore; // bad var totalScore = '' + this.reviewScore + ' total score'; // good var totalScore = this.reviewScore + ' total score';
  • 對數字使用?parseInt?并且總是帶上類型轉換的基數.,如parseInt(value, 10)

    var inputValue = '4'; // bad var val = new Number(inputValue); // bad var val = +inputValue; // bad var val = inputValue >> 0; // bad var val = parseInt(inputValue); // good var val = Number(inputValue); // good var val = parseInt(inputValue, 10); // good /** * parseInt was the reason my code was slow. * Bitshifting the String to coerce it to a * Number made it a lot faster. */ var val = inputValue >> 0;
  • 布爾值:

    var age = 0; // bad var hasAge = new Boolean(age); // good var hasAge = Boolean(age); // good var hasAge = !!age;

命名約定

  • 避免單個字符名,讓你的變量名有描述意義。

    // bad
    function q() { // ...stuff... } // good function query() { // ..stuff.. }
  • 當命名對象、函數和實例時使用駝峰命名規則

    // bad
    var OBJEcttsssss = {}; var this_is_my_object = {}; var this-is-my-object = {}; function c() {}; var u = new user({ name: 'Bob Parr' }); // good var thisIsMyObject = {}; function thisIsMyFunction() {}; var user = new User({ name: 'Bob Parr' });
  • 當命名構造函數或類時使用駝峰式大寫

    // bad
    function user(options) { this.name = options.name; } var bad = new user({ name: 'nope' }); // good function User(options) { this.name = options.name; } var good = new User({ name: 'yup' });
  • 命名私有屬性時前面加個下劃線?_

    // bad
    this.__firstName__ = 'Panda'; this.firstName_ = 'Panda'; // good this._firstName = 'Panda';
  • 當保存對?this?的引用時使用?self(python 風格),避免this issue.Angular建議使用vm(MVVM模式中view-model)

    // good
    function() { var self = this; return function() { console.log(self); }; }

存取器

  • 屬性的存取器函數不是必需的
  • 如果你確實有存取器函數的話使用getVal() 和 setVal(‘hello’),java getter、setter風格或者jQuery風格

  • 如果屬性是布爾值,使用isVal() 或 hasVal()

    // bad
    if (!dragon.age()) { return false; } // good if (!dragon.hasAge()) { return false; }
  • 可以創建get()和set()函數,但是要保持一致

    function Jedi(options) { options || (options = {}); var lightsaber = options.lightsaber || 'blue'; this.set('lightsaber', lightsaber); } Jedi.prototype.set = function(key, val) { this[key] = val; }; Jedi.prototype.get = function(key) { return this[key]; };

構造器

  • 給對象原型分配方法,而不是用一個新的對象覆蓋原型,覆蓋原型會使繼承出現問題。

    function Jedi() { console.log('new jedi'); } // bad Jedi.prototype = { fight: function fight() { console.log('fighting'); }, block: function block() { console.log('blocking'); } }; // good Jedi.prototype.fight = function fight() { console.log('fighting'); }; Jedi.prototype.block = function block() { console.log('blocking'); };
  • 方法可以返回?this?幫助方法可鏈。

    // bad
    Jedi.prototype.jump = function() { this.jumping = true; return true; }; Jedi.prototype.setHeight = function(height) { this.height = height; }; var luke = new Jedi(); luke.jump(); // => true luke.setHeight(20) // => undefined // good Jedi.prototype.jump = function() { this.jumping = true; return this; }; Jedi.prototype.setHeight = function(height) { this.height = height; return this; }; var luke = new Jedi(); luke.jump() .setHeight(20);
  • 可以寫一個自定義的toString()方法,但是確保它工作正常并且不會有副作用。

    function Jedi(options) { options || (options = {}); this.name = options.name || 'no name'; } Jedi.prototype.getName = function getName() { return this.name; }; Jedi.prototype.toString = function toString() { return 'Jedi - ' + this.getName(); };

事件

  • 當給事件附加數據時,傳入一個哈希而不是原始值,這可以讓后面的貢獻者加入更多數據到事件數據里而不用找出并更新那個事件的事件處理器

    // bad
    $(this).trigger('listingUpdated', listing.id); ... $(this).on('listingUpdated', function(e, listingId) { // do something with listingId });

    更好:

    // good
    $(this).trigger('listingUpdated', { listingId : listing.id }); ... $(this).on('listingUpdated', function(e, data) { // do something with data.listingId });

模塊

  • 這個文件應該以駝峰命名,并在同名文件夾下,同時導出的時候名字一致
  • 對于公開API庫可以考慮加入一個名為noConflict()的方法來設置導出的模塊為之前的版本并返回它
  • 總是在模塊頂部聲明?'use strict';,引入[JSHint規范](http://jshint.com/)

    // fancyInput/fancyInput.js(function(global) {  'use strict'; var previousFancyInput = global.FancyInput; function FancyInput(options) { this.options = options || {}; } FancyInput.noConflict = function noConflict() { global.FancyInput = previousFancyInput; return FancyInput; }; global.FancyInput = FancyInput; })(this);

jQuery

  • 對于jQuery對象以$開頭,以和原生DOM節點區分。

    // bad
    var menu = $(".menu"); // good var $menu = $(".menu");
  • 緩存jQuery查詢

    // bad
    function setSidebar() { $('.sidebar').hide(); // ...stuff... $('.sidebar').css({ 'background-color': 'pink' }); } // good function setSidebar() { var $sidebar = $('.sidebar'); $sidebar.hide(); // ...stuff... $sidebar.css({ 'background-color': 'pink' }); }
  • 對DOM查詢使用級聯的?$('.sidebar ul')?或?$('.sidebar ul'),jsPerf

  • 對有作用域的jQuery對象查詢使用?find

    // bad
    $('.sidebar', 'ul').hide(); // bad $('.sidebar').find('ul').hide(); // good $('.sidebar ul').hide(); // good $('.sidebar > ul').hide(); // good (slower) $sidebar.find('ul'); // good (faster) $($sidebar[0]).find('ul');
  • 每個頁面只使用一次document的ready事件,這樣便于調試與行為流跟蹤。

    $(function(){ //do your page init. });
  • 事件利用jQuery.on從頁面分離到JavaScript文件。

    // bad
    <a id="myLink" href="#" onclick="myEventHandler();"></a> // good <a id="myLink" href="#"></a> $("#myLink").on("click", myEventHandler); 
  • 對于Ajax使用promise方式。

        // bad$.ajax({ ... success : function(){ }, error : function(){ } }) // good $.ajax({. .. }).then( function( ){ // success }, function( ){ // error })
  • 利用promise的deferred對象解決延遲注冊問題。

    var dtd = $.Deferred(); // 新建一個deferred對象   var wait = function(dtd){     var tasks = function(){       alert("執行完畢!");       dtd.resolve(); // 改變deferred對象的執行狀態     };     setTimeout(tasks,5000);     return dtd;   };
  • HTML中Style、以及JavaScript中style移到CSS中class,在HTML、JavaScript中引入class,而不是直接style。

ECMAScript 5兼容性

盡量采用ES5方法,特別數組map、filter、forEach方法簡化日常開發。在老式IE瀏覽器中引入ES5-shim。或者也可以考慮引入underscore、lodash?常用輔助庫.?
- 參考Kangax的 ES5?compatibility table?
-?JavaScript工具庫之Lodash?
-?Babel-現在開始使用 ES6

HTML、CSS、JavaScript分離

  • 頁面DOM結構使用HTML,樣式則采用CSS,動態DOM操作JavaScript。不要混用在HTML中
  • 分離在不同類型文件,文件link。
  • HTML、CSS、JavaScript變量名都需要有業務價值。CSS以中劃線分割的全小寫命名,JavaScript則首字母小寫的駝峰命名。
  • CSS可引入Bootstrap、Foundation等出名響應式設計框架。以及SASS、LESS工具書寫CSS。
  • 對于CSS、JavaScript建議合并為單文件,減少Ajax的連接數。也可以引入AMD(Require.js)加載方式。
  • 對于內部大部分企業管理系統,可以嘗試采用前端 MVC框架組織代碼。如Angular、React + flux架構、Knockout等。
  • 對于兼容性可用Modernizr規范庫輔助。

使用jsHint

  • 前端項目中推薦引入jshint插件來規范項目編碼規范。以及一套完善的IDE配置。
  • 注意:jshint需要引入nodejs 工具grunt或gulp插件,建議企業級nodejs npm私服。

前端工具

  • 前端第三方JavaScript包管理工具bower(bower install jQuery),bower可以實現第三方庫的依賴解析、下載、升級管理等。建議建立企業級bower私服。
  • 前端構建工具,可以采用grunt或者gulp工具,可以實現html、css、js壓縮、驗證、測試,文件合并、watch和liveload等所有前端任務。建議企業級nodejs npm私服。
  • 前端開發IDE: WebStorm( Idea )、Sublime為最佳 。項目組統一IDE。IDE統一配置很重要。

轉載于:https://www.cnblogs.com/luyuan/p/8512413.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/281112.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/281112.shtml
英文地址,請注明出處:http://en.pswp.cn/news/281112.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

修改onlyoffice存儲為手動存儲關閉瀏覽器時不進行保存

原文同步自作者博客&#xff1a;https://www.daxueyiwu.com/post/704 相關官方API地址&#xff1a; 文件保存 回調處理程序 配置-編輯-定制-自動保存 配置-編輯-定制-forcesave 需要將: config.editorConfig.customization.forcesave改為true, 并且config.editorConfig.…

如何使用NVIDIA ShadowPlay錄制PC游戲

NVIDIA’s ShadowPlay, now known as NVIDIA Share, offers easy gameplay recording, live streaming, and even an FPS counter overlay. It can automatically record gameplay in the background–just on the PlayStation 4 and Xbox One–or only record gameplay when y…

.Net 7 的 R2R,Crossgen2是什么?

楔子來下這些概念R22,Crossgen2這兩個東西&#xff0c;跟前面講的AOT和CLR有異曲同工之妙&#xff0c;到底什么呢&#xff1f;本篇來看下。R2RR2R(ReadyToRun),是一種結合了AOT和CLR編譯模式&#xff0c;取其優點&#xff0c;拋其缺點的一種編譯方式。具體的呢&#xff0c;R2R包…

Java流

流分類 字節流字符流輸入流InputStreamReader輸出流OutputStream WriterInputStream:BufferedInputStream、DataInputStream、ObjectInputStreamOutputStream:BufferedOutputStream、DataOutputStream、ObjectOutputStream、PrintStream 標準流: System.in 、Syst…

Win7安裝OnlyOffice(不使用Docker)

原文同步自作者博客&#xff1a;https://www.daxueyiwu.com/post/741 1、安裝準備 &#xff08;1&#xff09;安裝Elang&#xff1a; 【注意事項】 a)Elang是為了給RabbitMQ使用的&#xff0c;因此在安裝Elang之前應確定RabbitMQ的版本及其所需的Elang版本。RabbitMQ的地址…

geek_享受How-To Geek用戶樣式腳本的好處

geekMost people may not be aware of it but there are two user style scripts that have been created just for use with the How-To Geek website. If you are curious then join us as we look at these two scripts at work. 大多數人可能不知道它&#xff0c;但是已經創…

.NET Core統一參數校驗、異常處理、結果返回

我們開發接口時&#xff0c;一般都會涉及到參數校驗、異常處理、封裝結果返回等處理。如果每個后端開發在參數校驗、異常處理等都是各寫各的&#xff0c;沒有統一處理的話&#xff0c;代碼就不優雅&#xff0c;也不容易維護。所以&#xff0c;我們需要統一校驗參數&#xff0c;…

Memcached 在linux上安裝筆記

第一種yum 方式安裝 Memcached 支持許多平臺&#xff1a;Linux、FreeBSD、Solaris、Mac OS&#xff0c;也可以安裝在Windows上。 第一步 Linux系統安裝memcached&#xff0c;首先要先安裝libevent庫 Ubuntu/Debian sudo apt-get install libevent libevent-deve 自動下…

onlyoffice回調函數controller方式實現

原文同步自作者博客&#xff1a;https://www.daxueyiwu.com/post/706 springboot實現的onlyoffice協同編輯網盤項目可以去作者博客。 上代碼&#xff1a; //新建報告GetMapping("report/createReport")public String CreatReport(HttpServletRequest request,Stri…

讀Bilgin Ibryam 新作 《Dapr 是一種10倍數 平臺》

Bilgin Ibryam 最近加入了開發者軟件初創公司Diagrid Inc&#xff0c;他是Apache Software Foundation 的 committer 和成員。他也是一個開源的布道師&#xff0c;并且是書籍 Kubernetes設計模式 和 Camel Design Patterns 的作者。早在2020年初 提出的Multi-Runtime Microserv…

如何在iPhone或iPad上使用Safari下載文件

Khamosh PathakKhamosh PathakIn your work or personal life, you’ll sometimes need to download a file on your iPhone or iPad. Using the new feature introduced in iOS 13 and iPadOS 13, you can now do this directly in Safari. No third-party app needed! 在工作…

java版左右手桌面盯盤軟件dstock V1.0

V1.0功能比較簡陋&#xff0c;先滿足自己桌面盯盤需要 V1.0 版本功能介紹&#xff1a; 1. 1s實時刷新盯盤數據 主要市面上的&#xff0c;符合我要求的桌面應用要VIP,窮啊&#xff0c;還是月月付&#xff0c;年年付&#xff0c;還是自己搞吧&#xff01; 2. 配置文件配置股票…

放大倍數超5萬倍的Memcached DDoS反射攻擊,怎么破?

歡迎大家前往騰訊云社區&#xff0c;獲取更多騰訊海量技術實踐干貨哦~ 作者&#xff1a;騰訊游戲云 背景&#xff1a;Memcached攻擊創造DDoS攻擊流量紀錄 近日&#xff0c;利用Memcached服務器實施反射DDoS攻擊的事件呈大幅上升趨勢。DDoS攻擊流量首次過T&#xff0c;引發業界熱…

C# WPF TabControl控件用法詳解

概述TabControl我之前有講過一節&#xff0c;內容詳見&#xff1a;C# WPF TabControl用法指南(精品)&#xff0c;上節主要講解了tabcontrol控件的左右翻頁&#xff0c;以及頁面篩選&#xff0c;以及數據綁定等內容&#xff0c;這節內容繼續接續上節內容進行擴展講解&#xff0c…

pixel 解鎖_如何在Google Pixel 4和Pixel 4 XL上禁用面部解鎖

pixel 解鎖Justin Duino賈斯汀杜伊諾(Justin Duino)Face Unlock is one of the Google Pixel 4 and Pixel 4 XL’s flagship features. But if the facial recognition is a form of biometric security you’re uncomfortable with, you can delete your face data right off …

【實戰】將多個不規則多級表頭的工作表合并為一個規范的一維表數據結果表...

最近在項目里&#xff0c;有個臨時的小需求&#xff0c;需要將一些行列交叉結構的表格進行匯總合并&#xff0c;轉換成規范的一維表數據結構進行后續的分析使用。從一開始想到的使用VBA拼接字符串方式&#xff0c;完成PowerQuery的M語言查詢字符串&#xff0c;然后轉換成使用插…

#if defined(__cplusplus)

由于C編譯器需要支持函數的重載&#xff0c;會改變函數的名稱&#xff0c;因此dll的導出函數通常是標準C定義的。這就使得C和C的互相調用變得很常見。但是有時可能又會直接用C來調用&#xff0c;不想重新寫代碼&#xff0c;讓標準C編寫的dll函數定義在C和C編譯器下都能編譯通過…

happiness[國家集訓隊2011(吳確)]

【試題來源】 2011中國國家集訓隊命題答辯【問題描述】 高一一班的座位表是個n*m的矩陣&#xff0c;經過一個學期的相處&#xff0c;每個同學和前后左右相鄰的同學互相成為了好朋友。這學期要分文理科了&#xff0c;每個同學對于選擇文科與理科有著自己的喜悅值&#xff0c;而一…

sketch怎么移動圖層_什么是Photoshop Express,Fix,Mix和Sketch移動應用程序?

sketch怎么移動圖層Adobe’s approach to mobile apps seems to be “The More, The Better”. Right now, there are five Photoshop branded apps available for iOS and Android. Adobe的移動應用程序方法似乎是“越多越好”。 目前&#xff0c;有五個適用于iOS和Android的P…

imessage_如何在iPhone和iPad上的iMessage組中提及某人

imessageKhamosh PathakKhamosh PathakSometimes, it’s difficult to get someone’s attention in a large iMessage group chat on your iPhone or iPad. However, if you mention that person specifically in a message, your friend will receive a notification about i…