【js實例】Array類型的9個數組方法,Date類型的41個日期方法,Function類型

?前文提要:【js實例】js中的5種基本數據類型和9種操作符

Array類型的9個數組方法

Array中有9個數組方法:

1.檢測數組 2.轉換方法 3.棧方法 4.隊列方法 5.沖排序方法
6.操作方法 7.位置方法 8.迭代方法 9.歸并方法

在實例中介紹,實例如下

/*
Array類型
js數組中的每一項可以用來保存任何類型的數據;js數組的大小是可以動態調整的
*/
var colors = ["red", "blue", "green"];
alert(colors[0]);    //red
alert(colors[1]);    //blue
alert(colors[2]);    //green
alert(colors[3]);    //undefined
alert(colors.length);
/*
1.
檢測數組:
instanceof(), isArray()
*/
if (colors instanceof Array) {alert("yes"); //yes }if (Array.isArray(colors)) {alert("yes"); //yes } /* 轉換方法:
toString(), toLocaleString(), valueOf() alert()要接收字符串參數,當傳入alert()的不是字符串參數時它會在后臺調用toString()方法
*///返回一個字符串,字符串由數組中每個值的字符串組成,并且以逗號分隔 alert(colors.toString()); //通常和toString()方法一樣,但是它是調用數組中每一項的toLocaleString()方法 alert(colors.toLocaleString()); //先是valueOf()方法,調用toString()方法,(valueOf返回的是數組) alert(colors.valueOf()); alert(colors);//join接收一個參數,返回以參數做分隔符的所有數組項的字符串 alert(colors.join("~")); //red~blue~green/* 棧方法:push()和pop() push()向數組中添加元素,返回修改后數組的長度 pop()移除數組中最后一項,返回移除的項 */var colors = ["red", "blue", "green"]; var count = colors.push("white", "yellow"); alert(count); //5 alert(colors.length); //5 alert(colors); //red,blue,green,white,yellowvar item = colors.pop(); alert(item); //yellow alert(colors.length); //4 alert(colors); //red,blue,green,white/* 隊列方法:shift()和unshift() shift()移除數組的第一項并返回移除的項 unshift()在數組的第一項之前添加任意項,并返回數組的長度 */ var colors = ["red", "blue", "green"]; var item = colors.shift(); //shift() alert(item); //red alert(colors.length); //2 alert(colors); //blue,green //unshift() var count = colors.unshift("white", "yellow"); alert(count); //4 alert(colors.length); //4 alert(colors); //white,yellow,blue,green/* 排序方法:reverse()和sort() reverse()會反轉數組想的順序,返回排序后的數組 sort()比較的是字符串,接收的參數會調用每個數組項的toString()方法,返回排序后的數組 sort()接收的參數也可以是函數 */ //reverse() var value = [1, 3, 5, 2, 10]; var values = value.reverse(); alert(value); //10,2,5,3,1 alert(values); //10,2,5,3,1//sort() var value = [1, 3, 5, 2, 10]; var values = value.sort(); alert(value); //1,10,2,3,5 alert(values); //1,10,2,3,5/* 操作方法:concat(), slice()和splice() concat()創建當前數組的副本,若有參數則將其添加到副本數組尾部,最后返回新創建的數組slice()基于當前數組創建新數組,但是不改變原數組;接收兩個參數start, end start為返回項的起始位置,end為返回項的結束位置(具體見例子),splice(),接收2個或3個參數通常用于刪除,插入或替換(插入和替換都要產生刪除操作,刪除項數可為0),返回刪除的項 刪除:splice(x, y); x為刪除的起始位置,y為要刪除的項數 插入和替換(通過改變參數實現):splice(x, y, z); x為起始位置,y為要刪除的項數,z為要插入的項;z可以是任意多個項 */ //concat() var colors = ["red", "blue", "green"]; var colors2 = colors.concat(); alert(colors); //red,blue,green alert(colors2); //red,blue,green var colors3 = colors.concat("yellow", ["black", "brown"]); alert(colors); //red,blue,green alert(colors3); //red,blue,green,yellow,black,brown//slice() var colors = ["red", "blue", "green", "yellow", "black"]; //1.若有一個參數,則返回從起始位置到原數組末尾所組成的數組 var colors2 = colors.slice(1); //2.若有兩個參數,則返回從起始位置到結束位置前一項所組成的數組 var colors3 = colors.slice(1, 4); //3.若start < end時返回空數組 var colors4 = colors.slice(2, 1); //4.若參數為負數,則參數加上數組長度作為start或者end var colors5 = colors.slice(-3, -1);alert(colors); //red,blue,green,yellow,black alert(colors2); //blue,green,yellow,black alert(colors3); //blue,green,yellow alert(colors4); //返回空數組,屏幕上顯示空白警告框 alert(colors5); //green,yellow//splice() //刪除 var colors = ["red", "blue", "green", "yellow", "black"]; var remove = colors.splice(1, 2); alert(colors); //red,yellow,black alert(remove); //blue,green//插入 var colors = ["red", "blue", "green", "yellow", "black"]; var remove2 = colors.splice(1, 0, "white", "brown"); //刪除項數為0 alert(colors); //red,white,brown,blue,green,yellow,black alert(remove2); //空數組//替換 var colors = ["red", "blue", "green", "yellow", "black"]; var remove2 = colors.splice(1, 1, "white", "brown"); //刪除項數為1 alert(colors); //red,white,brown,green,yellow,black alert(remove2); //blue/* 位置方法:indexOf()和lastIndexOf() 兩個方法用于返回查找項在數組中的位置,未找到返回-1;都接收兩個參數x和y, x:要查找的項;y:查找起始點位置的索引(可選參數)indexOf()從數組開頭向后查找查找并返回查找參數的第一個位置,找不到返回-1; lastIndexOf()從數組末尾向前查找,返回查找參數的第一個位置注意:要查找的項必須嚴格相等(===) */ var numbers = [1, 2, 3, 4, 5, 4, 3, 2, 1]; //indexOf() alert(numbers.indexOf(4)); //3 alert(numbers.indexOf(4, 4)); //5 alert(numbers.indexOf(4, 6)) //-1 alert(numbers.indexOf(10)); //-1 //lastIndexOf() alert(numbers.lastIndexOf(4)); //5 alert(numbers.lastIndexOf(4, 4)); //3 alert(numbers.lastIndexOf(4, 2)); //-1 alert(numbers.lastIndexOf(10)) //-1//要查找的項必須嚴格相等(===) var person = {name : "Nicholas"}; var people = [{name : "Nicholas"}]; var morePeople = [person]; //注意這是數組 alert(people.indexOf(person)); //-1 alert(morePeople.indexOf(person)); //0/* 迭代方法:every(), filter(), forEach(), map(), some() 每個方法接收兩個參數:函數參數x,運行該函數的作用域對象y 函數參數x接收三個參數:數組項的值,該項在數組中的位置和數組對象本身every():對數組中的每一項運行給定的函數,如果該函數對每一項都返回true,則返回true some():對數組中的每一項運行給定的函數,如果該函數中某一項返回true,則返回true filter():對數組中的每一項運行給定的函數,返回該函數會返回true的項組成的數組 forEach():對數組中的每一項運行給定的函數,無返回值 map():對數組中的每一項運行給定的函數,返回每次函數調用結果組成的數組 */var numbers = [1, 2, 3, 4, 5, 4, 3, 2, 1]; //every() var everyResult = numbers.every(function(item, index, array) {return (item > 2); }); alert(everyResult); //false//some() var someResult = numbers.some(function(item, index, array) {return (item > 2); }); alert(someResult); //true//filter() var filterResult = numbers.filter(function(item, index, array) {return (item > 2); }); alert(filterResult); //3,4,5,4,3//map() var mapResult = numbers.map(function(item, index, array) {return item * 2; }); alert(mapResult); //2,4,6,8,10,8,6,4,2/* 歸并方法:reduce()和reduceRight() 接收兩個參數:一個在數組每一項調用的函數x,作為歸并基礎的初始值y(可選) 函數x:接收四個參數,前一個值,當前值,項的索引和數組對象 reduce():從數組的第一項開始 reduceRight():從數組的最后一項開始 */var values = [1, 2, 3, 4, 5]; //reduce() var sum = values.reduce(function(prev, cur, index, array) {return prev + cur; }); alert(sum); //"15"//redeceRight() var sum2 = values.reduceRight(function(prev, cur, index, array) {return prev + cur; }) alert(sum2); //"15"

?

Date類型的41個日期方法

Date類型可分為如下:

繼承的方法:Date(),?parse(),toLocaleString(),toString()和valueOf()方法;

日期格式化方法:

toDateString()
toTimeString()
toLocaleDateString()
toLocaleTimeString()
toUTCString()

日期/時間組件方法:getTime(),?getTimezoneOffset()等

具體在實例中給出:

/*
Date類型
*/
var now = new Date();
alert(now);
//繼承的方法
//Date.parse()接收一個表示日期的字符串參數,根據參數返回相依日期的毫秒數;
//ECMA-262規范沒有定義此函數支持的格式,應地區實現而異
var someDate = new Date(Date.parse("May 25, 2004"));    
alert(someDate);    //Tue May 25 2004 00:00:00 GMT+0800//Date.UTC()方法接收7個參數:年year,月month(0開始),日day(1-31),小時hour(0-23),分鐘min,秒s,毫秒ms
//year和month為必須參數;day默認為1,其它參數默認為0var y2k = new Date(Date.UTC(2000, 0));    
alert(y2k);            //Sat Jan 01 2000 08:00:00 GMT+0800var allFives = new Date(Date.UTC(2005, 4, 5, 17, 55, 55, 3600));
alert(allFives);    //Fri May 06 2005 01:55:58 GMT+0800//Date()構造函數會模仿Date.parse()和Date.UTC()方法
var d = new Date("May 25, 2004");
var dd = new Date(2005, 4, 5, 17, 55, 55, 3600);
alert(d);        //Tue May 25 2004 00:00:00 GMT+0800
alert(dd);        //Fri May 06 2005 01:55:58 GMT+0800/*
Date類型也重寫了toLocaleString(),toString()和valueOf()方法;
但是瀏覽器之間對toLocaleString()和toString()輸出不一致.下面輸出為火狐瀏覽器下輸出
*/
var date = new Date("1, 1, 2001");
alert(date);                    //Mon Jan 01 2001 00:00:00 GMT+0800
alert(date.toLocaleString());    //2001/1/1 上午12:00:00
alert(date.toString());            //Mon Jan 01 2001 00:00:00 GMT+0800
//注意:valueOf()方法返回的是日期的毫秒數
alert(date.valueOf());            //978278400000/*
日期格式化的方法
這些方法也是因瀏覽器而異,以下為火狐瀏覽器輸出
*/
var date = new Date("1, 1, 2001");
//toDateString():以特定于實現的格式顯示星期幾,月,日和年
alert(date.toDateString());        //Mon Jan 01 2001
//toTimeString():以特定于實現的格式顯示時,分,秒和時區
alert(date.toTimeString());        //00:00:00 GMT+0800
//toLocaleDateString():以特定于地區的格式顯示星期幾,月,日和年
alert(date.toLocaleDateString());        //2001/1/1
//toLocaleTimeString():以特定于實現的格式顯示時,分,秒
alert(date.toLocaleTimeString());        //上午12:00:00
//toUTCString():以特定與實現的格式完整的UTC日期
alert(date.toUTCString());        //Sun, 31 Dec 2000 16:00:00 GMT/*
日期/時間組件方法
*/
var date = new Date(2001, 1, 1);
//返回表示日期的毫秒數,與valueOf()返回的值相同
alert(date.getTime());
//返回本地時間與UTC世紀那相差的分鐘數
alert(date.getTimezoneOffset());
//以毫秒數設置日期,傳入參數為毫秒
alert(date.setTime(3600000000000));//參數為為毫秒數//
var date = new Date(2001, 1, 1);
//取得四位數的年份
alert(date.getFullYear());
//返回UTC日期的4位數年份
alert(date.getUTCFullYear());
//設置日期年份,傳入參數必須為4位數
alert(date.setFullYear(2002));    //參數為年
//設置UTC日期年份,傳入參數必須為4位數
alert(date.setUTCFullYear(2003));//參數為年//月:0-11
var date = new Date(2001, 1, 1);
//返回日期中的月份
alert(date.getMonth());
//返回UTC日期中的月份
alert(date.getUTCMonth());
//設置日期的月份,傳入參數必須大于0,超過則增加年份
alert(date.setMonth(1));//參數為月
//設置UTC日期的月份,傳入參數必須大于0,超過則增加年份
alert(date.setUTCMonth(2));//參數為月//日:1-31
var date = new Date(2001, 1, 1);
//返回日期月份中的天數
alert(date.getDate());
//返回UTC日期月份中的天數
alert(date.getUTCDate());
//設置日期月份中的天數
alert(date.setDate(23));//參數為日
//設置UTC日期月份中的天數
alert(date.setUTCDate(24));//參數為日//星期:1-6,0表示星期日
var date = new Date(2001, 1, 1);
//返回日期中的星期幾
alert(date.getDay(2));
//返回UTC日期中的星期幾
alert(date.getUTCDay(3));//時:0-23
var date = new Date(2001, 1, 1);
//返回日期中的小時數
alert(date.getHours());
//返回UTC日期中的小時數
alert(date.getUTCHours());
//設置日期中的小時數
alert(date.setHours(2));//參數為時
//設置UTC日期中的小時數
alert(date.setUTCHours(3));//參數為時//分:0-59
var date = new Date(2001, 1, 1);
//返回日期中的分鐘數
alert(date.getMinutes());
//返回UTC日期中的分鐘數
alert(date.getUTCMinutes());
//設置日期中的分鐘數
alert(date.setMinutes(34));//參數為分
//設置UTC日期中的分鐘數
alert(date.setUTCMinutes(35));//參數為分//秒:0-59
var date = new Date(2001, 1, 1);
//返回日期中的秒數
alert(date.getSeconds());
//返回UTC日期中的秒數
alert(date.getUTCSeconds());
//設置日期中的秒數
alert(date.setSeconds(45));//參數為秒
//設置UTC日期中的秒數
alert(date.setUTCSeconds(46));//參數為秒//毫秒
var date = new Date(2001, 1, 1);
//返回日期中的毫秒數
alert(date.getMilliseconds());
//返回UTC日期中的毫秒數
alert(date.getUTCMilliseconds());
//設置日期中的毫秒數
alert(date.setMillseconds(3454));//參數為毫秒
//設置UTC日期中的毫秒數
alert(date.setUTCMillseconds(1111));//參數為毫秒

?

Function類型

/*
函數Function 類型
*/
/*
1.函數是對象,函數名是只想函數對象的指針,不會與函數綁定(函數是對象,函數名是指針)
*/
function sum(num1, num2) {return num1 + num2;
}
alert(sum(10, 10));    //20var anotherSum = sum;
alert(anotherSum(10, 10));    //20//sum是函數的指針并不與函數綁定
sum = null;
alert(anotherSum(10, 10));    //20/*
2.函數沒有重載
*/
function addNum(num) {return num + 100;
}function addNum(num) {return num + 200;
}alert(addNum(100));    //300/*
3.解析器會通過“函數聲明提升”將函數聲明添加到執行環境中去,而函數表達式則須解析器執行到它所在的代碼行才會被執行
*/
alert(sum(10, 10));    //20
function sum(num1, num2) {return num1 + num2;
}alert(sum2(19, 10));    //error
var sum2 = function(num1, num2) {return num1 + num2;
}/*
4.函數的內部屬性:arguments和this,callee,caller
注意:不能在嚴格模式下使用callee,caller
*/
//arguments保存函數的參數,該對象還有一個callee的屬性,callee是一個指針,指向擁有arguments對象的函數
function factorial(num) {if (num <= 1) {return -1;} else {return num * arguments.callee(num - 1);}
}alert(4);        //24//this引用的是函數執行的環境對象。
var color = "red";
var o = {color : "blue"};function showColor() {alert(this.color);
}//直接調用函數則this引用的環境對象是window
showColor();        //red
alert(window.color);//red
//this引用的環境對象是o,所以調用的是o中的color
o.showColor();        //red/*
caller保存至調用當前函數的函數的引用(在全局作用域中調用當前函數則值為null),除opera早期版本不支持外其他都支持,
注意:ECMAScript并沒有定義這個屬性
*/
function outer() {inner();
}function inner() {alert(inner.caller);
}outer();    //顯示outer函數的源代碼/*
apply(), call()
apply():接收兩個參數x,y;x為運行函數的作用域,y為參數數組(可以為Array實例)
call():第一個參數與apply()類似,但是后面的參數不已數組形式傳遞,而是直接傳遞給數組
*/
function sum(num1, num2) {return num1 + num2;
}//注意:在嚴格模式下,未指定環境對象而調用函數則this值不會轉型為window,this此時為undefined
function callSum1(num1, num2) {return sum.apply(this, arguments);
}
function callSum2(num1, num2) {return sum.apply(this, [num1, num2]);
}
alert(callsum1(10 ,10));    //20
alert(callsum2(10 ,10));    //20function sum(num1, num2) {return num1 + num2;
}
function callSum(num1, num2) {return sum.call(this, num1, num2);
}
alert(callSum(10, 10));        //20

?

轉載于:https://www.cnblogs.com/libra-yong/p/6903705.html

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

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

相關文章

調用詠南中間件插件演示

function GetSvrData(const accountNo, defineId: WideString; inParams: OleVariant): OleVariant; virtual; abstract; // accountNo&#xff0c;帳套編號 // defineId3位插件編號2位自定義編號&#xff0c;defineId必須是唯一的 // inParams&#xff0c;TDataSet.Params的OL…

龍芯與飛騰roadmap

飛騰roadmap 龍芯roadmap 龍芯系列處理器芯片是龍芯中科技術有限公司研發的具有自主知識產權的處理器芯片&#xff0c;產品以32位和64位單核及多核CPU/SOC為主&#xff0c;主要面向國家安全、高端嵌入式、個人電腦、服務器和高性能機等應用。產品線包括龍芯1號小CPU、龍芯2號中…

vim 多窗口操作

1、打開多個窗口打開多個窗口的命令以下幾個&#xff1a;橫向切割窗口:new窗口名(保存后就是文件名) :split窗口名&#xff0c;也可以簡寫為:sp窗口名縱向切割窗口名:vsplit窗口名&#xff0c;也可以簡寫為&#xff1a;vsp窗口名2、關閉多窗口可以用&#xff1a;q!&#xff0c;…

BZOJ 2440 完全平方數(莫比烏斯-容斥原理)

題目鏈接&#xff1a;http://61.187.179.132/JudgeOnline/problem.php?id2440 題意&#xff1a;給定K。求不是完全平方數&#xff08;這里1不算完全平方數&#xff09;的倍數的數字組成的數字集合S中第K小的數字是多少&#xff1f; 思路&#xff1a;首先&#xff0c;答案不超過…

在Eclipse中添加JDK源碼包

一直有這想要在Eclipse直接閱讀JDK的需求&#xff0c;之前用的都是反編譯的&#xff0c;由于我用的反編譯的插件去掉了源碼內容的注釋&#xff0c;所以想直接導入JDK源碼包&#xff1a; 詳細步驟&#xff1a; 打開Eclipse, 菜單欄 選擇 Window 下拉種選取 Preferences 窗口. 以…

南橋芯片與北橋芯片

什么是芯片組 芯片組&#xff08;英語&#xff1a;Chipset&#xff09;是一組共同工作的集成電路“芯片”&#xff0c;并作為一個產品銷售。它負責將計算機的微處理器和計算機的其他部分相連接&#xff0c;是決定主板級別的重要部件。以往&#xff0c;芯片組由多顆芯片組成&am…

spark 應用場景2-身高統計

原文引自&#xff1a;http://blog.csdn.net/fengzhimohan/article/details/78564610 a. 案例描述 本案例假設我們需要對某個省的人口 (10萬) 性別還有身高進行統計&#xff0c;需要計算出男女人數&#xff0c;男性中的最高和最低身高&#xff0c;以及女性中的最高和最低身高。本…

阿里云OSS linux使用備忘錄

ossutil config example: accessKeyId "AccessKeyId"; accessKeySecret "AccessKeySecret"; ###以上兩個在 https://help.aliyun.com/knowledge_detail/38738.html endPoint "http://oss-cn-beijing.aliyuncs.com";轉載于:https://www.cnblog…

纏繞多年的PCIE通道數問題終于完全明白了,歡迎指正

CPU的PCIE通道數&#xff0c;之前一直都是一個眾說紛紜的問題很多人都會問到&#xff0c;主板上不同的M.2接口&#xff0c;接SSD性能是否一樣&#xff0c;接太多的SSD&#xff0c;是否會占用顯卡的PCIE帶寬&#xff0c;今天我又看了幾篇網上的文章&#xff0c;終于十分清楚地搞…

vue-router實例

最近剛剛用vue寫了個公司項目&#xff0c;使用vue-cli構建的&#xff0c;算是中大型項目吧&#xff0c;然后這里想記錄并且分享一下其中的知識點&#xff0c;希望對大家有幫助,后期會逐漸分享&#xff1b;話不多說&#xff0c;直接上代碼&#xff01;&#xff01; app.vue 1 &l…

React學習小結(二)

一、組件的嵌套 1 <!DOCTYPE html>2 <html>3 <head>4 <meta charset"UTF-8">5 <title></title>6 <script src"react.min.js" type"text/javascript" charset"utf-8"></script>7 <…

PCIE2.0/PCIE3.0/PCIE4.0/PCIE5.0接口的帶寬、速率計算

一、PCIE接口速率&#xff1a; 二、PCIE相關概念&#xff1a; 傳輸速率為每秒傳輸量GT/s&#xff0c;而不是每秒位數Gbps&#xff0c;因為傳輸量包括不提供額外吞吐量的開銷位&#xff1b; 比如 PCIe 1.x和PCIe 2.x使用8b / 10b編碼方案&#xff0c;導致占用了20% &#xff08…

華為交換機同一vlan不同網段的通信

在VLANIF接口下配置主從IP地址&#xff0c;可以實現同一VLAN多個網段用戶間的互通。 某VLAN10內兩個主機Host_1和Host_2分別屬于網段10.1.1.1/24和10.1.2.1/24&#xff0c;要求兩主機互通。 可以在Switch上進行如下配置&#xff1a; [Switch] interface gigabitethernet 0/0/1 …

hql語法

HQL查詢&#xff1a;Criteria查詢對查詢條件進行了面向對象封裝&#xff0c;符合編程人員的思維方式&#xff0c;不過HQL(Hibernate Query Lanaguage)查詢提供了更加豐富的和靈活的查詢特性&#xff0c;因此Hibernate將HQL查詢方式立為官方推薦的標準查詢方式&#xff0c;HQL查…

四五月份:關鍵詞是溝通、繪畫和SQL

例行總結一下四五月份的感受。 關鍵詞有三個&#xff1a;溝通、繪畫和SQL。 整體來說&#xff0c;這兩個月在努力跟這三個關鍵詞死磕&#xff0c;略有些進展&#xff0c;因此匯報一下。 雖然這三個關鍵詞從重要度來說是從左到右的&#xff0c;但從敘述來講&#xff0c;還是先從…

InfiniBand簡介

一&#xff0e;什么是infiniband InfiniBand架構是一種支持多并發鏈接的“轉換線纜”技術&#xff0c;它是新一代服務器硬件平臺的I/O標準。由于它具有高帶寬、低延時、 高可擴展性的特點&#xff0c;它非常適用于服務器與服務器&#xff08;比如復制&#xff0c;分布式工作等…

程序員的視角:java GC

GC&#xff08;Garbage Collection 垃圾回收&#xff09;的概念隨著 java 的流行而被人們所熟知。 實際 GC 最早起源于20世紀60年代的 LISP 語言&#xff0c;是一種自動的內存管理機制。 GC 要解決的問題有 3 個&#xff1a;1. 回收什么&#xff1f;&#xff08;what&#xff0…

spring mvc攔截器HandlerInterceptor

本文主要介紹springmvc中的攔截器&#xff0c;包括攔截器定義和的配置&#xff0c;然后演示了一個鏈式攔截的測試示例&#xff0c;最后通過一個登錄認證的例子展示了攔截器的應用 攔截定義 定義攔截器&#xff0c;實現HandlerInterceptor接口。接口中提供三個方法。 public cla…

mysql show 語句大全

mysql show 語句大全 show open tables; 基于本人對MySQL的使用&#xff0c;現將常用的MySQL show 語句列舉如下&#xff1a; 1.show databases ; // 顯示mysql中所有數據庫的名稱 2.show tables [from database_name]; // 顯示當前數據庫中所有表的名稱 3.show columns from …