JavaScript中獲取到物件名

2021-08-15 00:06:56 字數 539 閱讀 9727

我們經常要判斷使用者傳遞進來的物件名是不是合法的,那麼我們就需要獲取到該物件的物件名,在chrome有提供直接獲取到物件名的方法,而在ie中就需要正則或者字串切割,這麼使用正則

//版本1

function

getname

(fun)else

}//版本2

function

getname

(fun)

//版本3

function

getname

(fun)

//版本4

function

getname

(fun)

//呼叫

function

person

(){}

var ps = new person();

getname(ps.constractor); //通過獲取到constractor從而獲取到建構函式

//很多框架中比較喜歡用版本4

泛型中獲取到Class

在公共基礎類中 public class commondaoimpl extends hibernatedaosupport implements icommondao 泛型轉換 private class entity class genericsuperclass.getclass this.g...

如何在頁面中獲取到ModelAndView繫結的值

以下內容 springmvc中通過modelandview進行後台與頁面的資料互動,那麼如何在頁面中獲取modelandview繫結的值呢?1 在jsp中通過el表示式進行獲取 比較常用 後台 modelandview model new modelandview model.addobject n...

Unity 中關於獲取到物體的方式

在unity中獲取到某個物體的方式有很多種,下面我們來分別介紹一下。1 public gameobject target 通過外部賦值來進行獲取,但是在小專案中還可以使用,大的專案會管理非常混亂,尤其是在打包assetbundle時,依賴關係很難處理。2 gameobject.find 這種獲取物體...