As per the Metamask API documentation:
MetaMask injects a global API into websites visited by its users at
window.ethereum (Also available at window.web3.currentProvider for
legacy reasons). This API allows websites to request user login, load
data from blockchains the user has a connection to, and suggest the
user sign messages and transactions. You can use this API to detect
the user of a web3 browser.
Edit:
You can see what window.web3 returns by opening a console in Chrome using "F12" (or whatever browser you're using), and typing window.web3:
> window.web3
Proxy {_requestManager: a, currentProvider: Proxy, eth: n, db: e.exports, shh: s, …}
[[Handler]]: Object
[[Target]]: n
bzz: e.exports {_requestManager: a, blockNetworkRead: ƒ, syncEnabled: ƒ, swapEnabled: ƒ, download: ƒ, …}
currentProvider: Proxy {selectedAddress: undefined, networkVersion: "4", _events: {…}, _eventsCount: 1, _maxListeners: 100, …}
db: e.exports {_requestManager: a, putString: ƒ, getString: ƒ, putHex: ƒ, getHex: ƒ}
eth: n {_requestManager: a, getBalance: ƒ, getStorageAt: ƒ, getCode: ƒ, getBlock: ƒ, …}
net: e.exports {_requestManager: a, getListening: ƒ, getPeerCount: ƒ}
personal: e.exports {_requestManager: a, newAccount: ƒ, importRawKey: ƒ, unlockAccount: ƒ, ecRecover: ƒ, …}
providers: {HttpProvider: ƒ, IpcProvider: ƒ}
setProvider: ƒ ()
settings: e.exports {defaultBlock: "latest", defaultAccount: undefined}
shh: s {_requestManager: a, version: ƒ, info: ƒ, setMaxMessageSize: ƒ, setMinPoW: ƒ, …}
version: {api: "0.20.3", getNode: ƒ, getNetwork: ƒ, …}
_extend: ƒ (e)
_requestManager: a {provider: Proxy, polls: {…}, timeout: null}
__proto__: Object
[[IsRevoked]]: false
The same can be done for window.ethereum.
window.web3returns. – Marcellvs Mar 13 '19 at 10:22window.web3.currentProvider. There was an upgrade that introducedwindow.ethereum, which was slightly different to the old API. This is why they are different.window.web3.currentProviderstill exists "for legacy reasons", i.e. because some people will still be using it in their code. – Richard Horrocks Mar 13 '19 at 14:35window.web3.currentProviderandwindow.web3. And why isn't therewindow.ethereum.currentProvider? Does the old version offer more functionality? – Marcellvs Mar 13 '19 at 15:40window.web3.currentProviderbasically provided a subset of information relating towindow.web3. By instantiating aWeb3()object you would get access to everything. That same information is now available fromwindow.ethereum(I think with some minor differences, hence the upgrade.) You can still get access to everything by instantiatingWeb3()in the same way (e.g.window.web3 = new Web3(ethereum);rather thanwindow.web3 = new Web3(web3.currentProvider);). – Richard Horrocks Mar 13 '19 at 16:07.currentProviderisn't necessary anymore. – Marcellvs Mar 13 '19 at 22:43