Summarize:

Both your Mac and your TV need to be connected to the same Wi-Fi network to use AirPlay. Consult the user's manual or manufacturer's website for your TV to learn how to connect it to a Wi-Fi network. Read Method 4 of "How To Connect to a Wireless Internet Connection" to learn how to connect your Mac to a Wi-Fi network. Not all TVs support AirPlay. If your TV does not support AirPlay, you can purchase an Apple TV streaming box and use it to connect to your TV. Make sure it is connected to the same Wi-Fi network as your Mac. It's in the menu bar in the upper-left corner of the desktop. This displays the Apple menu as a drop-down. It's in the Apple menu on your Mac. It's below an icon that resembles a monitor in the System Preferences menu. It's the checkbox next to "Show mirroring options in the menu bar when available". This displays the AirPlay icon in the menu at the top of the screen. It's the icon that resembles a monitor with a triangle at the bottom. This shows available devices you can connect to with AirPlay. This displays two display options in a pop-up window. If you want to the monitor to display what is on your MacBook display, select "Mirror Built-in Display". If you want to use it as a second display, select "Use as a Separate Display". This Connects to the monitor using AirPlay. To disconnect from the monitor, click the AirPlay icon in the Menu bar, then click Turn off AirPlay.
Connect both your Mac and TV to the same wi-fi network. Click the Apple icon. Click System Preferences. Click Display. Click the checkbox at the bottom of the Display window. Click the AirPlay icon in the menu bar. Click the monitor you want to connect to. Click Mirror Built-in Display or Use as Separate Display.