let ob = {};
ob[/\ing?$/] = `I match all strings end with "ing"`; //key is instance of 'RegEXp'
ob["/\ing?$/"] = `I am sure it is not same as the above`; //key is instance of 'String'
console.log(
`- Key RegExp :
==> ${ob[/\ing?$/]}
`);
console.log(
`- Key String :
==> ${ob["/\ing?$/"]}
`);
The above string demonstrates that literal object property can be an instance of RegExp class and it can be also String of course and they are totally different .
My question is how to check if the type property using Object.keys or alternative . Known that using Object.keys, this method casts all keys (properties) to string ?
Object.keys(ob);
//--> Expected :[/\ing?$/, "/\ing?$/"]
//--> Actual : ["/\ing?$/", "/ing?$/"]
key is instance of 'RegEXp'- are you sure about that?typeofdisagrees with your assertionRegExpmatch the example string?