發表文章

目前顯示的是 3月, 2021的文章

[javascript] (重要) 物件 & 陣列

重點整理 在 JavaScript 中,除了七種純值外,其他資料型別都是物件型別。 陣列(array)以 [] 中括號表示 ,可以想像成是有順序的箱子之集合。 宣告陣列:  let arr = [] 放入值:  arr.push(value) 取得值: arr[index] 取得陣列長度:  arr.length 物件(object)以 {} 大括號表示,是被賦予值的名稱之組合,在記憶體中是 名稱/值 的配對。 物件裡的值:可以是任何東西(例如:純值、函式、陣列等。) 宣告物件:  let obj = {} 放入組合:  obj.name = 'mia'  or  obj[name] = 'mia' 取出值: obj.name  or  obj[name] 將組合從物件刪除: delete obj.name https://miahsuwork.medium.com/%E7%AC%AC%E5%9B%9B%E9%80%B1-javascript-%E9%99%A3%E5%88%97-array-%E8%88%87-%E7%89%A9%E4%BB%B6-object-25f13e3d3c92 陣列(Array) 是包含許多值的集合,是有順序性的物件。 [補充說明] 陣列可以放入沒有順序性或沒有關聯性的資料嗎? 可以,但就失去了陣列的意義。 大部分的程式語言,陣列可以包含一連串相同型別的東西(例如:數字陣列、字串陣列、物件陣列),JS 的陣列與其他語言不太相同的是,因為動態型別的關係,他會立刻知道東西的型別,因此他可以放入不相同型別的東西。 陣列在記憶體中是 索引/值 的配對。 舉例來說:儲存全班同學的數學成績,資料是有順序性及關聯性的(有序集合、列隊),因此就適合用陣列儲存。 通常會搭配迴(loop)使用。 用中括號表示[]。   創造陣列 方法1. 創造一個空陣列(常見用法) :  let score = [] 方法2. 利用函式建構式創造一個空物件:  let score = new Array() 語法: let score = [ value, value, value, value, …] 語法說明: 1. 索引  index ...

JavaScript:使用 Array.map、Object.values 和 Object.keys 處理一連串的資料

  JavaScript:使用 Array.map、Object.values 和 Object.keys 處理一連串的資料 https://cythilya.github.io/2018/06/17/array-and-object-handling/ 使用  Array.map 、 Object.values  和  Object.keys  處理「物件中有物件」和「陣列中有物件」的情況。 物件中有物件 一個物件包含了一串物件。 範例如下,這裡有一串 ID 與名字。 { " 1234567890 " : { id : " 1234567890 " , name : " Nina Ricci " , }, " 2345678901 " : { id : " 2345678901 " , name : " Hello Kitty " , }, " 3456789012 " : { id : " 3456789012 " , name : " Pusheen the cat " , }, } 取得 key 的陣列 在這一連串資料下取得 key 的陣列。 使用  Object.keys  取得物件的鍵值,組成陣列後回傳。 const idList = Object . keys ( list ); idList // ["1234567890", "2345678901", "3456789012"] 取得 value 的陣列 在這一連串資料下取得 value 之特性屬性的陣列。 使用  Object.values  取得物件的 value,組成陣列。 承上,使用  Array.map  將陣列中的特定屬性值取出,組成新陣列後回傳。 const nameList = Object . values ( list ). map ( item => item . name ); nameL...

SAS Viya 程式

  https://leoyeh-me.gitbook.io/sas-book/di-11-zhang-kai-fa-cheng-shi https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=mlov&docsetTarget=home.htm&locale=zh-TW

[jQuery] Excel 轉 JSON

http://jsfiddle.net/d2atnbrt/3/  <input type="file" id="my_file_input" /> <div id='my_file_output'></div> <table class="easyui-datagrid" id="dg">     <thead>         <tr>             <th data-options="field:'code'">Code</th>             <th data-options="field:'name'">Name</th>                      </tr>     </thead>     <tbody>              </tbody> </table> var oFileIn; $(function() {     oFileIn = document.getElementById('my_file_input');     if(oFileIn.addEventListener) {         oFileIn.addEventListener('change', filePicked, false);     } }); function filePicked(oEvent) {     // Get The File From The Input     var oFile = o...

easyui datagrid- loadData

 http://code.reloado.com/oeasyrik1/104/edit#javascript,html <html> <head>   <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui//themes/default/easyui.css">   <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">   <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css">   <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.min.js"></script>   <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>   <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-scrollview.js"></script>   <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-dnd.js"></scrip...

jQuery 必填欄位

圖片
 http://www.jeasyui.com/tutorial/app/crud2.php https://www.twcode01.com/jquery/jquery-plugin-validate.html Step 1: Define DataGrid in HTML tag <table id = "dg" title = "My Users" style = " width : 550px ; height : 250px " toolbar = "#toolbar" idField = "id" rownumbers = "true" fitColumns = "true" singleSelect = "true" > <thead> <tr> <th field = "firstname" width = "50" editor = "{type:'validatebox',options:{required:true}}" > First Name </th> <th field = "lastname" width = "50" editor = "{type:'validatebox',options:{required:true}}" > Last Name </th> <th field = "phone" width = "50" editor = "text" > Phone </th> <th field = "email" width = "...