-2

This line:

console.log('crypto: ' + crypto);

prints crypto: [object Crypto]

If I do this:

var crypto = "mystring";
console.log('crypto: ' + crypto);

I still get crypto: [object Crypto]. I would expect it to print crypto: mystring. Why doesn't it?

Vytautas
  • 452
  • 3
  • 11

2 Answers2

1

As you want to override the crypto object with some string, you can do so like this

delete crypto
var crypto = "mystring"
console.log("crypto = " + crypto) // crypto = mystring
pavi2410
  • 1,220
  • 2
  • 12
  • 16
0

Crypto is an library in Javascript. Thats why there is a problem i guess. I tried replacing crypto with other words and it worked fine.

delete crypto var crypto = "mystring" console.log("crypto = " + crypto) // crypto = mystring

crypto. This library is an object oriented cryptography toolkit that implements several fundamental cryptographic algorithms including TWOFISH, SERPENT, RIJNDAEL, RSA with key-generation and SHA(SHA-1,224,256,384,512) for JavaScript. ... The unique feature of this library is asynchronous processing.

AkRoy
  • 343
  • 4
  • 10