I'm just getting started with Solidity and Truffle, and I'm quite confused regarding this example code:
App = { web3Provider: null, contracts: {}, ... initWeb3: function() { // Is there an injected web3 instance? if (typeof web3 !== 'undefined') { App.web3Provider = web3.currentProvider; web3 = new Web3(web3.currentProvider); } else { // If no injected web3 instance is detected, fallback to the TestRPC. App.web3Provider = new web3.providers.HttpProvider('http://localhost:8545'); web3 = new Web3(App.web3Provider); } return App.initContract(); }, ... } In the InitWeb3 function, it checks the type of a variable named web3, but it doesn't seem to be instantiated anywhere. I read that programs like MetaMask can "inject" a web3 instance, but how does this work? How does my program see it?